Modifier and Type | Class and Description |
---|---|
class |
GreenMartian
This class models a GreenMartian which is a subclass of Martian
|
class |
RedMartian
This class models a RedMartian which is a subclass of Martian
|
Modifier and Type | Field and Description |
---|---|
protected ArrayList<Martian> |
MartianManager.martians
Stores subclass instances of
Martian . |
Modifier and Type | Method and Description |
---|---|
Martian |
MartianManager.getMartianAt(int i)
|
Martian |
MartianManager.getMartianClosestTo(int id)
Returns the Martian in
MartianManager.martians that has an id
closest to the id supplied; Note: “closest” doesn’t mean the next martian,
For example, if you have martians with ids: 3, 4, 7, 8, 9 and you call the method with 5,
then the martian with id=4 should be returned. |
Martian |
MartianManager.getMartianClosestTo(Martian martian)
Returns the Martian in
MartianManager.martians that is closest to Martian
martian as measured by id . |
Martian |
MartianManager.getMartianWithId(int id)
Returns the
Martian with id or null if not found. |
Martian |
MartianManager.removeMartian(int id)
Removes the
Martian with id from martians
and from teleporters if it is a Teleporter . |
Modifier and Type | Method and Description |
---|---|
ArrayList<Martian> |
MartianManager.battle(ArrayList<Martian> invaders)
This method accepts a list of
invaders , which are Martian s. |
ArrayList<Martian> |
MartianManager.battle2(ArrayList<Martian> invaders)
DO NOT WRITE THIS, It was for an alternate version of the battle method.
|
ArrayList<Martian> |
MartianManager.getSortedMartians()
Returns a sorted list of
Martians according to their id . |
Modifier and Type | Method and Description |
---|---|
boolean |
MartianManager.addMartian(Martian m)
|
int |
Martian.compareTo(Martian m)
Implements Java’s
compareTo so that Martians (either red or green) are compared based on
their id ’s which results in the usual ascending sorted order. |
Martian |
MartianManager.getMartianClosestTo(Martian martian)
Returns the Martian in
MartianManager.martians that is closest to Martian
martian as measured by id . |
private int |
MartianManager.getPower(Martian m)
OPTIONAL METHOD - NOT REQUIRED, Returns the power for the input Martian.
|
Modifier and Type | Method and Description |
---|---|
ArrayList<Martian> |
MartianManager.battle(ArrayList<Martian> invaders)
This method accepts a list of
invaders , which are Martian s. |
ArrayList<Martian> |
MartianManager.battle2(ArrayList<Martian> invaders)
DO NOT WRITE THIS, It was for an alternate version of the battle method.
|