Question
Life is designed to run in a grid of infinite size. John Conway initially created Life on a Go board, 19 x 19. We will
Life is designed to run in a grid of infinite size. John Conway initially created Life on a Go board, 19 x 19. We will use this simplification for our implementation. Create a class to implement Life. The implementation can use a two-dimensional array to represent the cells in the game. Override the subclass Object's toString() method to allow System.out.println() toprint out your game board.You will convert the game board field (a two dimensional array) into a String and return that. For example, if you use . to represent dead cells and O to represent live cells, a spaced out grid of characters works well.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . O . . . . . . . . O O . . . . . . . . O . . . . . . . . O O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . O O . . . . . . . . . . . . . . . . O . . O . . . . . . . . . . . . . . . . O O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . O O O . . . . . . . . . . . . . . . . . . . . . . . . . . . . O . . . . . . . . . . . . . . . . O . O . . . . . . . . . . . . . . . . . O O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
This example uses one space between each character that represents a cell. Due to the ratio of height to width of many printing fonts, this spacing makes the cells relatively square. In the application method, provide an initial state for your game. Print out the initial state by calling "System.out.println(game)" (or whatever you call your game of Life object). System.out.printlnwill call your objects toString method to convert your game board into a String in order to print it to the console.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started