Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

o What are you asked to do? You have 3 main tasks to complete in this lab. 1/ You are first going to design a

image text in transcribedimage text in transcribed

o What are you asked to do? You have 3 main tasks to complete in this lab. 1/ You are first going to design a new user-defined type GameOfLife (defined in a java file called GameOfLife.java). This new type is described as follows: (highlighted is what you have to complete) Attributes: o Size: int o Board: int[][] + this is a square board, same number of rows and columns o Previous: int[][] this 2D array will store a copy of the game of life board. Constructors: o Default constructor: Given to you o Constructor that takes a size as input (this will be the number of rows as well as the number of columns of your board and previous) Constructor that take a 2D array as an input (its size will be the size of the board and previous; its content is to be copied into previous) Getter: o getBoard returns the current board oneStep: o Takes no parameter and is a void method O It consists in transforming the current board into its next shape (board at next time stamp). neighbors: Takes two indices (representing a row index and a column index). o Computes the number of neighbors the corresponding cell on the board has. evolution: o Takes an integer n, which represents the number of evolution steps we need to conduct. Transforms the board into the board after n steps of evolution (i.e., n successive calls to oneStep). Note: you can use more methods (as helper methods for the above methods). However, you need to stick at least to the ones above. 2/ You have to test that your implementation of the game of life is correct. You are expected to do so using JUnit testing, in a file called GOLTester.java. In this file, you have to test the following class methods of the GameOfLife type (5 tests at least per method): neighbors(int, int) oneStep) evolution (int) In particular, you should test the behavior of your two versions of the game of life on at least the following boards: 3/ You can see that there are two methods oneStep in the file GameOfLife.java. Explain what property of OOP describes this situation. What should you turn in? You should submit your 2 java files: GameOfLife.java and GOLTester.java. o What are you asked to do? You have 3 main tasks to complete in this lab. 1/ You are first going to design a new user-defined type GameOfLife (defined in a java file called GameOfLife.java). This new type is described as follows: (highlighted is what you have to complete) Attributes: o Size: int o Board: int[][] + this is a square board, same number of rows and columns o Previous: int[][] this 2D array will store a copy of the game of life board. Constructors: o Default constructor: Given to you o Constructor that takes a size as input (this will be the number of rows as well as the number of columns of your board and previous) Constructor that take a 2D array as an input (its size will be the size of the board and previous; its content is to be copied into previous) Getter: o getBoard returns the current board oneStep: o Takes no parameter and is a void method O It consists in transforming the current board into its next shape (board at next time stamp). neighbors: Takes two indices (representing a row index and a column index). o Computes the number of neighbors the corresponding cell on the board has. evolution: o Takes an integer n, which represents the number of evolution steps we need to conduct. Transforms the board into the board after n steps of evolution (i.e., n successive calls to oneStep). Note: you can use more methods (as helper methods for the above methods). However, you need to stick at least to the ones above. 2/ You have to test that your implementation of the game of life is correct. You are expected to do so using JUnit testing, in a file called GOLTester.java. In this file, you have to test the following class methods of the GameOfLife type (5 tests at least per method): neighbors(int, int) oneStep) evolution (int) In particular, you should test the behavior of your two versions of the game of life on at least the following boards: 3/ You can see that there are two methods oneStep in the file GameOfLife.java. Explain what property of OOP describes this situation. What should you turn in? You should submit your 2 java files: GameOfLife.java and GOLTester.java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

What are bond issue costs? What is an underwriter?

Answered: 1 week ago

Question

3. Did you seek anyones advice?

Answered: 1 week ago

Question

7. What traps should she avoid?

Answered: 1 week ago

Question

5. What decision-making model would you advocate to this person?

Answered: 1 week ago