Lab 3: Munch Game
Lab 3 Due Date: Monday, July 18, 11:00 pm
Background:
Lab 2 will allow you to exercise your
understanding of linked lists, iterators, and queues by implementing
two classes to finish the game Munch.
Getting Started
Download
the lab3.zip
file by clicking on this link. Save the zip file to your desktop and
unzip the files. You will see the directory for lab2. Inside lab2
you should see the following files:
- Caterpillar.java
fully implemented class that is models the caterpillars used in the
game; make no modifications to this file
- Pellets.java
a fully implemented class used to represent all the food elements
available to the caterpillars in this game; make
no modifications to this file
- MunchGame.java
a fully implemented class used to control all elements of the the game; make no modifications to this file
- ListNode.java
a fully implemented class for the Nodes that will be used to uild the
linked lists in the lists and queue that we implement in this lab
- SimpleList.java
an interface for this lab which will be implemented by the class LinkedSimpleList.
- Queue.java
an interface for this lab which will
be implemented by the class MyQueue
- MyLinkedList.java
a class to be implemented as a linked list using the ListNode class.
This class is actually not used in the Munch Game, but is an exercise
to practice working with an external Node class, as opposed to the
inner Node class we have been using in recitation. It has a main method
for testing the implementation.
- LinkedSimpleList.java
The class that implements the SimpleList interface to be used as part
of the solution for the MunchGame. This class must be implemented with
the ListNode class that is provided with this project (do not use an inner
node class). You will be
adding an iterator for this class as an inner class.
- MyQueue.java
The class that implements the Queue interface to be used as part
of the solution for the MunchGame. This class must be implemented with
the ListNode class that is provided with this project (do not use an inner
node class) You will be adding an iterator for this
class as an inner class.
Setting up
Eclipse
- Move the lab3
directory to the Eclipse workspace
on your machine.
- Very
often, students using Windows machines may find that the lab3 directory actually contains two
other directories Mac_OSX and lab3. It is THIS (interior) lab3 that you want to use in setting
up your Eclipse project.
- Start Eclipse by
selecting it from the Application menu on the Macintosh, or the Program
menu on Windows.
- Set up the Eclipse worskspace on your computer as
directed in the Eclipse Set-up Reference.
- Go to the menu: File->New->Project.
- Select Java Project. Click on Next.
- Enter lab3
as the name of the project. (You should see a message The
specified external location already exists...
and that Eclipse will try to open the associated elements of this
project. If you do not see this message, check that you placed the lab3 directory
in the workspace correctly, and that you typed the name of the
directory, lab3, as the name
of the project.) When you see the above message, click
on Finish.
- You may be asked if you want to switch to
the Java
Perspective. Click on Yes.
- In the Package
Explorer window on the left of the Eclipse window, open the lab3
project by clicking on the right-pointing triangle.
- Open the default
package in the same way. You should now see the .java source
files listed above
Your are now ready to start implementing your
solution. Use the Eclipse code completion and context help features to
build the appropriate classes.
Task
This assignment involves a simple computer game
called Munch. In Munch, two players each control a caterpillar to move
around in a world in which there are small green pellets of food. The
two players race to eat as many pellets as possible. When all of the
pellets are gone, the player who has managed to eat more pellets is the
winner.
For best results, you'll want a partner to
play the game with (or else try pitting your left hand against your
right ;-).
The implementation of the MunchGame makes use of two very simple data
structures, namely lists and queues. The Java interfaces for these data
structures, called SimpleList and Queue are found in the project directory.
Your task for this assignment is to provide implementations of the SimpleList and Queue, such that the basic operations enqueue, dequeue, add,
addFirst, getFirst, removeFirst and nextElement all run in constant
time, and that remove runs in linear time.
After you have designed your implementations of List and Queue, you
should rewrite the code in the SimpleList.java and SimpleQueue.java
files. (You will find it necessary to either discard or rewrite the
code in the MyLinkedList.java file as well.) Your implementations must
implement the SimpleList and Queue interfaces, and furthermore must
each operation must run in the amount of time specified in the comments
we have provided in the source files.
Your SimpleList and Queue implementations must also provide appropriate
iterators, which are expected by the MunchGame controller.
Provided Code
This assignment is intended to be a relatively small amount of work. We
have provided the complete code for the graphical user interface for
the Munch Game. Furthermore, we have provided documented Java
interfaces for the classes you are required to implement, in the
List.java and Queue.java files. Your task is simply to implement
MyQueue, LinkedSimpleList, and MyLinkedList the code in the project
directory, with thier appropriate iterators as private inner classes.
Grading for this project (75 points total)
- Timely submission (see course policies in Syllabus)
- 1 pt
- Correct submission (all the files needed for the
project, your work, not the original template) - 1 pt
- Documentation (make sure your name and section is
included as a comment in the Picture.java source file) - 1 pt
- Style (appropriate use of white space, indentation,
good identifiers, readability) - 1 pt
- The project compiles (grader will attempt to make
three corrections to lose only this point; if it still does not compile
then Execution and Correctness points are also lost) - 1 pt
- Execution
- MunchGame: You should be able to successfully play
the game with two players as demonstrated in class this week - 20
points
- MyLinkedList: Correctly executes the test main()
method that is part of this class. - 5 points
- Correctness
- MyQueue methods correctly implemented
- 10 pts each
- Iterator for MyQueue correctly implemented
- 5 pts
- LinkedSimpleList methods correctly implemented
- 10 pts each
- Iterator for LinkedSimpleList correctly implemented
- 5 pts
- MyLinkedList methods correctly implemented
- 15 pts each
Handing in your Solution
Your solutions should be in the form of .zip
files. When we grade your solution we will unzip the folder and execute
the project. If your project does not run you will lose the execution
points for that
lab.
Your Solution zip file must contain all the
files in your projects
Your solutions should be in the form of .zip files.
When
we grade your solution we will unzip the folder and execute the
project.
If your project does not run you will lose the submission points for
that
lab.
Your Solution zip file must contain all the files in your projects
You will be shown how to zip up the files for submission. Instructions
are also in the Windows
Tutorial or the Macintosh
Tutorial document that is available
Click on this link to Submit your zip file
|