| 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)
|
Martian |
MartianManager.getMartianClosestTo(Martian martian)
|
Martian |
MartianManager.getMartianWithId(int id)
Returns the
Martian with id or null if not found. |
Martian |
MartianManager.removeMartianAt(int loc)
Removes the
Martian at index loc from martians and returns it. |
Martian |
MartianManager.removeMartianWithId(int id)
Removes the
Martian with id from martians and returns it. |
| Modifier and Type | Method and Description |
|---|---|
ArrayList<Martian> |
MartianManager.battle(ArrayList<Martian> invaders)
This method accepts a list of
invaders, which battle with the martains resulting
in some Martians being removed from martians and returned in a list. |
ArrayList<Martian> |
MartianManager.battle2(ArrayList<Martian> invaders)
DO NOT WRITE THIS METHOD - It was for an alternate version of the battle method.
|
ArrayList<Martian> |
MartianManager.captureInvaders(ArrayList<Martian> invaders)
Adds all
invaders to this MartianManager that have
power greater than the average power of all Martians in this
MartianManager. |
ArrayList<Martian> |
MartianManager.getSortedMartians()
Returns a list of
Martians sorted according to their id. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
MartianManager.addMartian(Martian m)
Adds
m to MartianManager.martians provide that a Martian
doesn't already exist there with the same id. |
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)
|
| Modifier and Type | Method and Description |
|---|---|
void |
MartianManager.absorbColony(ArrayList<Martian> colony)
Add the
Martians in colony to this MartianManager |
ArrayList<Martian> |
MartianManager.battle(ArrayList<Martian> invaders)
This method accepts a list of
invaders, which battle with the martains resulting
in some Martians being removed from martians and returned in a list. |
ArrayList<Martian> |
MartianManager.battle2(ArrayList<Martian> invaders)
DO NOT WRITE THIS METHOD - It was for an alternate version of the battle method.
|
ArrayList<Martian> |
MartianManager.captureInvaders(ArrayList<Martian> invaders)
Adds all
invaders to this MartianManager that have
power greater than the average power of all Martians in this
MartianManager. |