 |
|
|
AbstractHost.java
|
import java.util.ArrayList;
import java.util.Collection;
/**
* This implementation of the Host includes the methods
* for handling the Virus infection. It holds the Collection
* of Viruses, and can check for an infected Host.
*
* @author Havard Rast Blok
*
*/
public abstract class AbstractHost implements Host {
/**
* Collection containing the Viruses of this Host.
*/
protected Collection<Virus> viruses = new ArrayList<Virus>();
/*
*
* @see Host#isInfected()
*/
public boolean isInfected() {
return !viruses.isEmpty();
}
/*
* @see Host#addVirus(Virus)
*/
public void addVirus(Virus virus) {
viruses.add(virus);
}
/*
*
* @see Host#getViruses()
*/
public Collection<Virus> getViruses() {
return viruses;
}
}
|
|
|
 |