Wednesday 26 October 2011

If anyone can finish this program for me in the next 2.5 hours ill give you 25 bucks via paypal--?

Fundamentals of Object-Oriented Programming in Java, CS 145, Spring 2010

Program 3 – Game of Life

10 points

Due: Friday, 4/30/2010 at 12:00 noon



Overall Task:

Write a program that allows a user to play the game of Life. This will give you an opportunity to practice with classes and objects, as well as with two-dimensional arrays.



Background:

You are to write a Java program that “plays” the game of Life. The Game of Life (or simply Life) is not a game in the conventional sense. There are no players, and no winning or losing. Once the %26quot;pieces%26quot; are placed in the starting position, the rules determine everything that happens later. Nevertheless, Life is full of surprises! In most cases, it is impossible to look at a starting position (or pattern) and see what will happen in the future. The only way to find out is to follow the rules of the game.

Life is played on a grid of square cells--like a chess board. A cell can be live or dead. A live cell is shown by putting a marker (an ‘X’) on its square. A dead cell is shown by leaving the square empty (or, for text display, we’ll use a dash (‘-‘). Each cell in the grid has a neighborhood consisting of the eight cells in every direction including diagonals.



To apply one step of the rules, we count the number of live neighbors for each cell. What happens next depends on this number.



A dead cell with exactly three live neighbors becomes a live cell (birth).





A live cell with two or three live neighbors stays alive (survival).







In all other cases, a cell dies or remains dead (overcrowding or loneliness).









Note: The number of live neighbors is always based on the cells before the rule was applied. In other words, we must first find all of the cells that change before changing any of them, e.g. by making the changes to a temporary “copy” grid and then re-applying them back to the current grid.



Life is one of the simplest examples of what is sometimes called %26quot;emergent complexity%26quot; or %26quot;self-organizing systems.%26quot; This subject area has captured the attention of scientists and mathematicians in diverse fields. It is the study of how elaborate patterns and behaviors can emerge from very simple rules. It helps us understand, for example, how the petals on a rose or the stripes on a zebra can arise from a tissue of living cells growing together. It can even help us understand the diversity of life that has evolved on earth.



Design Constraint:

You must follow the design provided. That is, you must use the classes that I provide to you, use names as I specify and use the method signatures where they are specified for the program that you turn in. I am giving you a JAR file, LifeStudent.jar, which contains some Java class files that will form the basis of your program. These files include:

Main.java – a small main program class to “drive” the game

Life.java – a class for the Life game overall

Grid.java – a class for the grid that holds the cells

We’ll later add Cell.java – a class for each cell



To pull the contents of this zip file into Eclipse, you can do the following:

1) Click on the link above, and save this file somewhere permanent (e.g. on your H: drive).

2) Open Eclipse to your normal workspace.

3) Create a Java project for this assignment (e.g. named Program 3 – GameOfLife or something similar).

4) Go down to the src folder.

5) Right-click on the src folder, and choose Import.

6) In the General section, choose Archive File, then Next.

7) Choose the Browse button, and browse to the location of the JAR file (e.g. if you saved it in H:\CS145, browse to that location).

8) Select the JAR file, and choose Open.

9) Back at the Archive File dialog, choose Finish.

10) The template Java files should now be in your GameOfLife project



Specific Tasks:

You should now do the following:

1) We need another class to represent one individual cell. We’ll make a new class called Cell to do this.

2) Add a Cell class to your project. Within the Cell class, add Cell data to hold a row, column and isAlive (a true/false “flag” value to signal whether the cell is alive or not).

3) Add the following methods, with these exact signatures:

a. Cell(); // default constructor

b. Cell(int row_value, int col_value, boolean isAliveFlag); // all-param constructor

c. boolean isCellAlive(); // tests if cell is alive

d. void setCell(int row_value, int col_value, bool isAliveFlag); // a utility method to allow you to set the cell instance variables while the program is running

e. String toString(); // converts the cell alive state to a string; “X” if alive, “-“ if dead

4) Implement the five methods listed above

5) Add a data member named grid to the Grid class definition (already provided, but not yet compl
If anyone can finish this program for me in the next 2.5 hours ill give you 25 bucks via paypal--?
Send money first.