CS110 Introduction to Computing
Spring 2006
Assignment#1: Modeling using Objects
Due in class on Tuesday, January 24, 2006
As you have seen this week, the primary step in designing programs involves identifying and defining objects, their properties and capabilities. In this exercise you will experiment with this aspect of program design, on pen and paper (or in a word processor). Pictured below is a screenshot of a popular arcade game from the 1980's: Pacman. Some of you may have played this game while growing up. The game has made a revival in the TV Games series. In fact, the local Gullifty's Restaurant has an original arcade version downstairs in their restaurant!
Description of the game: Pacman is a game in which the user moves a yellow, chomping pie (Pacman) around a two dimensional maze. The maze is filled with pellets that Pacman can eat. There are also four ghosts moving around the maze, trying to catch Pacman. If a ghost catches Pacman, Pacman dies. As in most video games, you can die multiple times. Pacman typically begins with two extra lives. Fortunately, there are a few special, larger pellets that render the ghosts harmless for a short period of time (in fact, during this time, Pacman can eat the ghosts). The user can control Pacman with the keyboard to move him left, right, up and down. Extra points can be obtained by eating fruit (like cherries) that randomly appears for short amounts of time. Eating all the pellets on the board brings Pacman to the next level. The goal of the game is to eat all the pellets without being killed by the ghosts.
What you have to do: In this assignment, you must think of three classes that would be used in a Pacman program. At least one of these classes must have multiple instances in the game. For each of the object classes, describe two attributes (instance variables) and two capabilities (methods). A one-line description will suffice for each attribute and capability. Do not worry about encoding the descriptions in Java. Concentrate only on modeling the objects. Look at the picture above, almost anything you see in ti could be an object. reread the description o fthe game. Objects frequently appear as nouns in the description of a process.
Just in case: You can play an online version of the game by clicking here.
Also: Choose one of the classes you defined above that would have multiple instances in pacman. Describe two instances of that class. State a possible value for each attribute of each instance. Do the values of the attributes have to be the same for both instances? Would the capabilities of the two instances be the same?
Hand in: A legible (preferably printed) version of your work from this assignment. Conclude your work by a short essay (just a few sentences) on your thoughts about your understanding of objects and the concepts you have learned so far.
This assignment was adapted from Andries van Dam's course CS015 at brown University.
Back to CS110 Spring 2006 Materials.