Question: You will implement a ping - pong array class for this assignment. The general principle of the array should follow the lectures. The terms used
You will implement a pingpong array class for this assignment.
The general principle of the array should follow the lectures. The terms used in describing this data structure will be explained in the lectures. Your implementation should provide the following: The Driver see the details later in this document. The pingpong arrays should properly allocate for and assign the references to Live and Next arrays properly. Pay particular attention to how Java uses assignment by reference and parameter passing by value, and how arrays though passed by value, behave differently when passed as arguments. The class should implement at least the following public You can implement any other methods as needed: A constructor that takes two integer arguments: for the number of rows and number of columns. This should initialize the cells with a random integer between Notice that this could be implemented in terms of a call to the other constructor mentioned below. Unfortunately, Java does not allow for default arguments to function parameters. A constructor that takes three integer arguments: number of rows, number of columns, and the value for the uniform initialization of all the cells. A Constructor that takes four integer arguments: number of rows and columns, and the last two arguments that give the lower and upper bounds for random numbers to be generated for each cell of the array. void setint myarg and int get methods for the specified elements of the Livearray. You will need the set method for both the Live and the Next arrays. It is up to you to implement them either as a single method with an extra parameter or as two separate methods. Array elements should not be accessible directly ie they should be privateprotected A method to swap the LiveArray and NextArray. Personally I do not recommend bending the rules of the language to use Collections::swap method as it seems to be intended for swapping elements within collections and not collections themselves. Besides, it is a three line code to do it directly. A method to count the nearest neighbor counts of a cell specified. A method to count the nextnearest neighbor counts of a cell. The above two methods should use the compact way of finding the neighbors of boundary cells using the modulus operator. A method that takes two integer arguments and resets the board to a random number between those two integer values both inclusive. A method that takes no arguments and resets the board or A method to print the LiveArray. This should print the board to standard out, as outlined below for printing. Notice Your implementation should provide the following:
The Driver see the details later in this document.
The pingpong arrays should properly allocate for and assign the references to Live and Next arrays properly. Pay particular attention to how Java uses assignment by reference and parameter passing by value, and how arrays though passed by value, behave differently when passed as arguments.
The class should implement at least the following public You can implement any other methods as needed:
A A constructor that takes two integer arguments: for the number of rows and number of columns. This should initialize the cells with a random integer between Notice that this could be implemented in terms of a call to the other constructor mentioned below. Unfortunately, Java does not allow for default arguments to function parameters.
B A constructor that takes three integer arguments: number of rows, number of columns, and the value for the uniform initialization of all the cells.
C A Constructor that takes four integer arguments: number of rows and columns, and the last two arguments that give the lower and upper bounds for random numbers to be generated for each cell of the array.
D void setint myarg and int get methods for the specified elements of the Livearray. You will need the set method for both the Live and the Next arrays. It is up to you to implement them either as a single method with an extra parameter or as two separate methods. Array elements should not be accessible directly ie they should be privateprotected
E A method to swap the LiveArray and NextArray. Personally I do not recommend bending the rules of the language to use Collections::swap method as it seems to be intended for swapping elements within collections and not collections themselves. Besides, it is a three line code to do it directly.
F A method to count the nearest neighbor counts of a cell specified.
G A method to count the nextnearest neighbor counts of a cell. The above two methods should use the compact way of finding the neighbors of boundary cells using the modulus operator.
H A method that takes two integer arguments and resets the board to a random number between those two integer values both inclusive.
I. A method that takes no arguments and resets the board o What the driver should do:
The Driver object shou
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
