Gettysburg College

CS 111
Computer Science I


ScreenSaverApp

General Description

The goal is to create an app for generating screen savers. The focus is on nested loops and 2D array (table) processing.

Create a new app called ScreenSaverApp and write the methods described below. Make sure to test each method carefully before moving on to the next one.

Use nested loops in the methods you write.

Working with Images

Recall from class that the following command will display an image on the screen (assuming the image colors are saved in a 2D table).
int[][] myImage = ... ;
canvas.drawImage( center-x-of-image, center-y-of-image, myImage );

Mystery Screen Saver

Write the following methods:

Game of Life Screen Saver

This problem is based on the Game of Life invented by John Conway:

We will use this game to generate screen saver patterns. The game is played on a rectangular board whose cells are either dead or alive (represented by the integers 0 and 1, respectively). The state of the board is updated according to the following rules:
1. for each cell in the table:
       2. count the number of live neighbors of the cell
       3. update the current cell as follows:
          - alive cell with 2 or 3 live neighbors remains alive
          - any other alive cell dies since it is lonely or overcrowded
          - dead cell with exactly 3 neighbors become alive
Write the following methods:

Showing the Screen Savers

Preliminaries

Here is how to let the user pick from a list of choices:

String choice = canvas.readSelection( some-prompt, the, list, of, string, choices );

int value = canvas.readSelection( some-prompt, the, list, of, int, choices );

double value = canvas.readSelection( some-prompt, the, list, of, double, choices );
Here is how to compare two strings:
string1.equals( string2 )

Here is how to convert double to int:

int width = (int) canvas.getWidth();

Write the following method: