Question: Java code Thank you No Junit test case needed for this lab. But you should run methods in main(String[] args) as demos. Failure to do

 Java code Thank you No Junit test case needed for thislab. But you should run methods in main(String[] args) as demos. Failureto do so will lose maximum of 15 points. See detail incanvas rubric The Game of Life is a well-known mathematical game thatgives rise to amazingly complex behavior, although it can be specified by

Java code

Thank you

No Junit test case needed for this lab. But you should run methods in main(String[] args) as demos. Failure to do so will lose maximum of 15 points. See detail in canvas rubric The Game of Life is a well-known mathematical game that gives rise to amazingly complex behavior, although it can be specified by a few simple rules. (It is not actually a game in the traditional sense, with players competing for a win.) Here are the rules. The game is played on a rectangular board. Each square can be either empty or occupied. At the beginning, you can specify empty and occupied cells in some way; then the game runs automatically. In each generation, the next generation is computed. A new cell is born on an empty square if it is surrounded by exactly three occupied neighbor cells. A cell dies of overcrowding if it is surrounded by four or more 1 Neighbors neighbors, and it dies of loneliness if it is surrounded by zero or one neighbor. A neighbor is an occupant of an adjacent square to the left, Figure right, top, or bottom or in a diagonal direction. Figure 21 shows a cell Neighborhood of a Cell and its neighbor cells. Cell Generation Generation 3 Generation 4 Generation 1 Generation 2 Figure 22 Glider Many configurations show interesting behavior when subjected to these rules. Figure 22 shows a glider, observed over five generations. After four generations, it is transformed into the identical shape, but located one square to the right and below. One of the more amazing configurations is the glider gun: a complex collection of cells that, after 30 moves, turns back into itself and a glider (see Figure 23). Figure 23 Glider Gun HHH DE Generation Generation 30 Generation 60 Generation 90 Generation 120 Generation 150 Write a class called Gameoflife which perform the game of life with given pattern. The skeleton class is given as follow: public class Gameoflife private boolean[][] board; private final int NUMROW; private final int NUMCOL; public GameofLife (boolean[][] initialBoard) { } public String toString() { } public void grow(int generation) {} private int checkNeighbor(int x, int y){ } Instructions: 1. private Boolean[][] board: The board is the game board occupied blocks are represented with true empty blocks are represented with false. 2. Public GameofLife(Boolean[][] initial Board){ } In the constructor, you should: Initiate NUMROW and NUMCOL. Use for loops to deep copy initial Board to board. Do not directly assign initialBoard to board 3. public String toString(){} This returns a string that represents the board state. For each occupied block, you should represent it as the lower-case letter "o". For each empty block, you should represent it as "+". For each block in a row, separate them with an empty space"". For example: + + + + + + + + + + + + + O + + + + + + + + + + + + + + + O O + + + + + + + + + + + + + + + + + + + + + 4. public void grow(int generation, int freqPrint) { } This function modifies the board. It should also frequently print the entire board using toString() to show how much the board has changed. The input generation controls how many generations your board is going to run. The input freqPrint controls how frequently the board got printed. If freq Print = 5, then the board is printed at every 5 generations. If freq Print = 1, then the board is printed in each generation In each generation, the program should start from the top left most block, check & update all blocks. o When checking, please use the helper function checkNeighbor(x, y) to get the number of occupied blocks in (x, y)'s neighbors as M (you should have better naming in your code) o if Mis 3, set the block (x, y) to occupied. o lf M is 2 and (x, y) itself is occupied, the block (x, y) keeps occupied o If M is 1 or 0 (loneliness), or greater than 3 (overcrowding), set the block to empty. Time complexity is not considered. There could be certain algorithms that can speed up the game. Implementing such algorithm is not required. 5. private int checkNeighbor(int x, int y){ } The function returns the number of occupied blocks of the neighbors of the block (x, y) Neighbors are consisted by the blocks around the given block (x, y) Neighbors does not include (x, y) The maximum number of neighbors (x, y) could have is 8. If the given block (x, y) are on the edge, the neighbors is consisted by the possible surrounding block. For example, The neighbor of (0,0) is (0, 1), (1, 0), (1, 1). The neighbor of (1, 0) is (0, 0), (0, 1), (1, 1), (1, 2), (0, 2). The neighbor of (1, 1) is (0,0), (0, 1), (0, 2), (1, 2), (2, 2), (2, 1), (2, 0), (1,0). Testing: To test your class, you should select at least one shape from each category listed as following. For your selected shape, you should generate the Boolean[][] board and create distinct Gameoflife object using the board generated (in your main methods). And then test your grow(generation, freqPrint) method with generation = 100 and freqPrint = 20 Implement a class ClockSystem that simulates a typical alarm/timer/stopwatch system that you find in your phone. Such system has: an alarm system that allows you to set one or more alarms, delete alarm, and activate any alarm. If an alarm is activated, it will print a message when the set time is reached.The alarm is deactivate after the message is printed stopwatch system allows you to start a timer (which is a simple counter incremented every second) and allows you to set lap time. You should be able to pause/resume and stop/reset the stopwatch. The time and number of laps are displayed when you reset or stop the stopwatch. timer system allows you to start a countdown timer (which is a simple counter decremented every second) and displayed a message when timer reaches 0. Provide the following: 1. Define ONE class with proper class name, appropriate methods with proper arguments and return types, member variables and constructors for the entire system. Each method/function should have a brief pseudo code describing its responsibilities. This is called version 1. 2. Write main to test all components of this system 3. Submit your design on paper by the end of class. 4. Re-design your system with multiple classes (as appropriate, review Chapter8 for details). This is called Version 2 5. Submit version 1 (yes, submit again as typed version) and version2 on canvas by Friday midnight (2/21). Provide a paragraphs explaining the differences of both version and benefits of doing that! Individual submission is expected. Don't forget to write your partner's name with your submission. Note: Define class(s) with all member variables & functions. Only write pseudo code inside each function. No implementation needed! This is a design exercise where you are deciding how classes should be designed. Grading: 5 points for in-class design, 15 points for canvas submission (version 1, version2 and explanation)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!