CS 201 - Lab 4

Particle Man

In this lab you will implement several classes which implement an interface called SuperHero.

As in Lab 3, you will be using JUnit tests as a specification.  The tests will indicate what behavior is required from each kind of object.

Getting Started

Import lab4.zip.  (File->Import...->General->Existing Projects into Workspace->Archive File).  You should see a project called lab4 in the Package Explorer.

Part I - Warm-Up

Add fields and methods to the Location class so that all of the tests in LocationTest pass.

Part II - SuperHero classes

Look at the interface called SuperHero.  It specifies several operations (abstract methods) that different kinds of SuperHero objects will support.  Specifically, an object whose class implements the SuperHero interface can return its name as a String object, its location as a Location object, can fight another SuperHero object, and can return its size as a member of the SuperHeroSize enumeration.

A SuperHero object should also define an equals method which compares itself against some other object, returning true if the objects are equal and false otherwise.

Here are the four kinds of SuperHero objects (along with a brief bio for each):

ParticleMan - does the things a particle can

PersonMan - lives his life in a garbage can

TriangleMan - hates Particle Man and Person Man

UniverseMan - is the size of the entire universe

The methods in the SuperHeroFactory class create instances of the various kinds of SuperHero objects.  Each method specifies a Location for the SuperHero object being created.

You will probably want to create a different class for each kind of SuperHero.  Each class you create (ParticleMan, PersonMan, etc.) should implement the SuperHero interface.

The JUnit tests in the SuperHeroTest class will show you the behavior of each kind of SuperHero object.  You are done when all of the test in both LocationTest and SuperHeroTest pass.

Hints

Start out by adding a ParticleMan class and creating/returning an instance of ParticleMan in the createParticleMan method in SuperHeroFactory.