evolution
Class HumanSelection


public class HumanSelection
implements Observer

A class to make human selections.


Constructor Summary
HumanSelection()
          Create a new human selection.

Method Summary
 protected voidadd(Human human)
          Add the given human.
 voidclear()
          Make this selection empty.
 booleanempty()
          Is this selection empty?
 protected HumangetLast()
          Get the most recently added human.
 booleanisActiveSelected(Human human)
          Check whether this human is the last selected human.
 booleanisSelected(Human human)
          Check whether the human is selected or not.
 Listlist()
          Return the list of humans in this selection.
 Humanpop()
          Return the last human added.
 voidprint()
          Prints the current selection to stdout (for debugging).
 protected voidremove(Human human)
          Remove the given human from the selection.
 booleanselect(Human human)
          Add/remove a human to the selection.
 intsize()
          The number of selected humans.
 voidupdate(Event evt)
          Triggered by the eventmanager when a human dies.

Constructor Detail

HumanSelection

public HumanSelection()
Create a new human selection.
Method Detail

add

protected void add(Human human)
Add the given human.

clear

public void clear()
Make this selection empty.

empty

public boolean empty()
Is this selection empty?

getLast

protected Human getLast()
Get the most recently added human. precondition: there must be humans in the selection

isActiveSelected

public boolean isActiveSelected(Human human)
Check whether this human is the last selected human.

isSelected

public boolean isSelected(Human human)
Check whether the human is selected or not.

list

public List list()
Return the list of humans in this selection.

pop

public Human pop()
throws java.util.NoSuchElementException
Return the last human added.
Throws:
NoSuchElementException - if the selection was empty.

print

public void print()
Prints the current selection to stdout (for debugging).

remove

protected void remove(Human human)
Remove the given human from the selection.

select

public boolean select(Human human)
Add/remove a human to the selection. If the human is already in the selection it is removed from the selection.
Returns: true if the human was added, false if the human was removed

size

public int size()
The number of selected humans.

update

public void update(Event evt)
Triggered by the eventmanager when a human dies.

Association Links

to Class evolution.Human

The list of humans in this selection.

Supplier Cardinality 1..*
Is directed
Type aggregation
associates <{evolution.Human}>

a gvijf production