Project 1: Moving Objects
Upon Completion of this project, students will be able to :
Implement small classes that conform to a set specification.
Use multiple classes together to solve a larger problem.
Use logic to enforce a valid internal state and perform computations.
The purpose of this project is to create the beginnings of a simple Java game involving moving objects that can be clicked on. The first thing to create is window for the game and a set of moving objects. Most of the code for the window has already been provided for you. Take a look at the classes GameFrame and DrawPanel in the Project 1 source code. Those classes are set up to display a window and to draw and move two objects on the screen: a circle and a rectangle. There is some code missing, however. Look at the sections marked with TODO comments. You will need to add some code there to initialize objects and link the code you create to the game. You should not modify any of the existing code as this stage. This is especially true for the variable and method declarations in those classes. (Notice that they all use interfaces instead of using a concrete class. That is they use ICircle instead of a class like Circle.)
The majority of the project is about implementing the following six interfaces:
Each interface lists the mandatory methods for the classes you need to implement. You may implement other methods in your classes to help you if you wish, but you must have at least those in the interface. Fairly detailed descriptions of what each method is required to do are listed above each method.
You must decide what data to include in your classes and how to store it.
While you are coding notice how the code is designed. For instance, there is a ICircle interface and a IDrawCircle interface. Why are these two not combined to form a circle that can draw itself? Would the single interface/class be more or less complicated than the separated versions? Would it be as clear as to what each interface/class represents?
Classes & Files
For grading purposes, the classes you implement must have certain names and provide certain constructors. They are as follows:
DrawArea implements IArea
constructor: public DrawArea(int x, int y, int width, int height)
Circle implements ICircle
constructor: public Circle(int rad, int x, int y, Color col)
DrawCircle implements IDrawCircle
constructor: public DrawCircle(ICircle cir, IVector vel, IArea drawArea)
DrawRect implements IDrawRect
constructor: public DrawRect(IRectangle rect, IVector vel, IArea drawArea)
Rectangle implements IRectangle
constructor: public Rectangle(int x, int y, int width, int height, Color col)
Vector implements IVector
constructor: public Vector(int vx, int vy)
You may include other constructors if you wish, but these must be there.
A typical implementation of the Circle class may start like this:
public class Circle implements ICircle
//add class variables
public Circle(int rad, int x, int y, Color col)
The implements ICircle after the class name tell the compiler that Circle conforms to the ICircle interface. If you do not have the methods defined in the body of ICircle, then the compiler will give you errors. (Hint: Eclipse will help you by giving you the option to fix those errors by automatically creating them. You can also just copy and paste the methods from ICircle and add a body to them.)
Do not change the interfaces! Doing so will cause the grader to error when you submit your work. Only modify you own classes and the areas in GameFrame and DrawPanel that are marked.
Test each class to see that it works as expected. Be sure to run your program and see what it does and if it is behaving as you wanted it to.
Submitting your Program
Submit your program through web-CAT. Web-CAT will provide you with 70% of your grade. The other 30% will come from the instructor.
Submit GameFrame, DrawPanel and the classes for the six interfaces you implemented. Do not submit the interface files (IArea, ICircle, etc.).
Edited 6 Years Ago by Tiff22: n/a