Package cz.cvut.fel.omo.SmartHome.alive
Class Creature
- java.lang.Object
-
- cz.cvut.fel.omo.SmartHome.alive.Creature
-
public class Creature extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private AbstractActionDevice
currentDevice
protected Floor
floor
private java.lang.String
name
protected Role
role
private double
satiety
private int
timeUntilFree
protected ClassificationEnum
wish
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
action()
The function assigns a device type to a person depending on his desire.void
addTimeUntilFree(int add)
Adds the number of iterations after which a person will be released.void
changeFloor(int i)
Changes the floor the person is on.void
changeFloorRandom()
Randomly changes the floor a person is on.void
continueAction()
Continues the action of a person on a current devicevoid
decreasePersonTime()
Decreases the number of iterations until the person is released.void
decreaseSatiety(int difference)
Reduces satiety.private void
doAction()
The function looks for what kind of activity a person can do on the floor on which he is located.void
doSomething()
The function adjusts the desire of a person according to his satiety.void
eat()
Increases a person's satiety.Creature
getHelp(AbstractActionDevice device)
Finds an adult to help the child fix the device or eat.boolean
isFree()
Checks if a person is currently freevoid
release()
Frees the person from activity.void
setCurrentDevice(AbstractActionDevice abstractActionDevice)
-
-
-
Field Detail
-
wish
protected ClassificationEnum wish
-
floor
protected Floor floor
-
role
protected Role role
-
currentDevice
private AbstractActionDevice currentDevice
-
timeUntilFree
private int timeUntilFree
-
satiety
private double satiety
-
name
private java.lang.String name
-
-
Constructor Detail
-
Creature
public Creature(Role role)
Creates person with role on random floor.- Parameters:
role
- string role of person
-
-
Method Detail
-
doSomething
public void doSomething()
The function adjusts the desire of a person according to his satiety. If the child is hungry, an adult feeds him.
-
doAction
private void doAction()
The function looks for what kind of activity a person can do on the floor on which he is located. If there are no free activities on the floor, it changes the floor and searches again.
-
changeFloor
public void changeFloor(int i)
Changes the floor the person is on.- Parameters:
i
- floor number
-
changeFloorRandom
public void changeFloorRandom()
Randomly changes the floor a person is on.
-
continueAction
public void continueAction()
Continues the action of a person on a current device
-
isFree
public boolean isFree()
Checks if a person is currently free- Returns:
- true if person is free false if person is busy
-
addTimeUntilFree
public void addTimeUntilFree(int add)
Adds the number of iterations after which a person will be released.- Parameters:
add
- number of iterations
-
decreasePersonTime
public void decreasePersonTime()
Decreases the number of iterations until the person is released.
-
getHelp
public Creature getHelp(AbstractActionDevice device)
Finds an adult to help the child fix the device or eat.- Parameters:
device
- device with which the child needs help.- Returns:
-
release
public void release()
Frees the person from activity.
-
decreaseSatiety
public void decreaseSatiety(int difference)
Reduces satiety.- Parameters:
difference
- number of satiety units
-
eat
public void eat()
Increases a person's satiety.
-
action
protected boolean action()
The function assigns a device type to a person depending on his desire.- Returns:
- true if there are suitable devices in the house. false if there are no suitable devices in the house.
-
setCurrentDevice
public void setCurrentDevice(AbstractActionDevice abstractActionDevice)
-
-