[an error occurred while processing this directive]
Domain for sale!
Start Search Contents Index Links About
Flu.java

/**
 
 @author Havard Rast Blok
 *
 */
public class Flu implements Virus, Cloneable {

  /**
   * The name of this Flue.
   */
  protected String name;
  
  /**
   * The Host which this intance of the Flu has infected.
   */
  protected Host host;
  
  /**
   * Constructs a Flu with the specified name.
   @param name
   */
  public Flu(String name) {
    this.name = name;
  }
  
  /*
   
   * @see Virus#infect(Host)
   */
  public void infect(Host host) {
    
    //if this Virus has already infected
    //the incoming host, do nothing
    if(this.host == host) {
      return;
    }
    
    //see if the given host is to be infected
    double probability = host.transmitProbability(this.host);
    if (Math.random() < probability) {

      // clone this virus
      Flu clone = null;
      clone = (Fluthis.clone();

      // infect the given host
      host.addVirus(clone);
      clone.host = host;
    }
  }

  /*
   * Clones this Flu.
   * Returns a Flu object with the same name.
   * @see java.lang.Object#clone()
   */
  public Object clone() {
    return new Flu(this.name);
  }
  
}


site: Håvard Rast Blok
mail:
updated: 16 July 2010