Page 309 - AP Computer Science A, 7th edition
P. 309
Saving and retrieving information is crucial to this program. The F ileH andler w ill t ak e c are of openFileForReading, openFileForWriting, closeFiles, loadClass, and saveClass. The FileHandler class should be written and tested right at the beginning, using a small dummy class list.
Score, ScoreList, and Student are easy classes to implement. When these are working, the programmer can go on to ClassList. Finally the Display GUI class, which will have the GradeBook, can be developed. This is an example of bottom-up development.
Example 3
A program simulates a game of Battleships, which is a game between two players, each of whom has a grid where ships are placed. Each player has five ships:
battleship cruiser submarine destroyer frigate o
o oooo o ooo
o oo
o o
The grids of the players’ fleets may look like this. Any two adjacent squares that are taken must belong to the same ship, i.e., different ships shouldn’t “touch.”