org.mars_sim.msp.core.person.medical
Class Medication

java.lang.Object
  extended by org.mars_sim.msp.core.person.medical.Medication
All Implemented Interfaces:
Serializable, Comparable<Medication>
Direct Known Subclasses:
AntiStressMedication

public abstract class Medication
extends Object
implements Serializable, Comparable<Medication>

An abstract class representing a medication a person has taken.

See Also:
Serialized Form

Constructor Summary
Medication(String name, double duration, Person person)
          Constructor.
 
Method Summary
 int compareTo(Medication o)
          Compares this object with the specified object for order.
 boolean equals(Object object)
           
 double getDuration()
          Gets the time duration of the medication.
 String getName()
          Gets the name of the medication.
 Person getPerson()
          Gets the person taking the medication.
 double getTimeElapsed()
          Gets the time elapsed since medication was taken.
 int hashCode()
           
 boolean isMedicated()
          Is the person under the influence of this medication?
 void timePassing(double time)
          Update the medication based on passing time.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Medication

public Medication(String name,
                  double duration,
                  Person person)
Constructor.

Parameters:
name - the name of the medication.
duration - the time duration (millisols).
person - the person to be medicated.
Method Detail

getName

public String getName()
Gets the name of the medication.

Returns:
name.

getDuration

public double getDuration()
Gets the time duration of the medication.

Returns:
duration (millisols).

getPerson

public Person getPerson()
Gets the person taking the medication.

Returns:
person.

getTimeElapsed

public double getTimeElapsed()
Gets the time elapsed since medication was taken.

Returns:
time (millisols).

timePassing

public void timePassing(double time)
Update the medication based on passing time. Child classes should override for other medical effects.

Parameters:
time - amount of time (millisols).

isMedicated

public boolean isMedicated()
Is the person under the influence of this medication?

Returns:
true if medicated.

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(Medication o)
Compares this object with the specified object for order.

Specified by:
compareTo in interface Comparable<Medication>
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.


Copyright © 2009-2013. All Rights Reserved.