Objective: To get experience using abstract classes and interfaces.
Due: Before class on Friday.
To start, you can either:
assign6
directory ORbin/
before the location of your
image files/home/courses/cs209/handouts/assign6
. To
edit the code in Eclipse, you'll need to copy the files somewhere
under your home directory.Now for the refactoring of your code:
@Override
annotation on the move
methods of your child classes, you should add that. If you get
errors, fix the errors (most likely caused by not using the
appropriate parameters).GamePiece
class so that it is
an abstract
class with an abstract
move
method.Game
class's animate
method
to have an array of GamePiece
objects, which contains
the GamePiece
objects that you just created. Iterate
through the objects, calling the move
method on each
object. (If you're getting errors, you likely didn't override
the move
method correctly.) You can look at my base
code
in /home/courses/cs209/handouts/assign6/Game.java
to
help guide you.
GamePiece
, discuss why
making GamePiece
abstract is a better approach to
organizing/designing the codeGame
,
move
method on
a GamePiece
object--a method that is abstract--and the
application does the "right" thing Modify your Assignment 5 MediaItem
class
to implement
the Comparable
interface. It
is up to you how you compare the items, although it should be
something that makes sense.
Let Eclipse do most of the work for you. (Note that this would be a little more straightforward if you added that the class should implement an interface during creation of the class.) When you start typing to implement the Comparable interface, use control-spacebar to let Eclipse complete "Comparable", which will automatically add the parameter. Eclipse will give you an error about unimplemented methods; click on the error and select to implement methods. That will give you the method template--you still need to fill in the method.
In your driver program, sort and display the elements in the array.
Save your output in a file.
Copy your project into an assign6
directory
in your turnin
directory.
You will be evaluated based on the following criteria: