Class AbstractActionDevice
- java.lang.Object
-
- cz.cvut.fel.omo.SmartHome.devices.AbstractDevice
-
- cz.cvut.fel.omo.SmartHome.devices.action.AbstractActionDevice
-
- Direct Known Subclasses:
AutomaticFeeder
,Bicycle
,BikeTrainer
,CoffeeMachine
,Electromobile
,GasStove
,MechanicalToy
,Microwave
,Projector
,RowingMachine
,Treadmill
,Turntable
,TV
public abstract class AbstractActionDevice extends AbstractDevice
Abstract class for action devices.
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassificationEnum
deviceClassification
private int
durationOfUsing
protected AbstractActionDeviceState
state
-
Fields inherited from class cz.cvut.fel.omo.SmartHome.devices.AbstractDevice
condition, consumption, deviceName, floor, instruction
-
-
Constructor Summary
Constructors Constructor Description AbstractActionDevice(Floor floor, java.lang.String deviceName, int durationOfUsing, Consumption consumption)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
action(Creature creature)
The method implemented by the state pattern.void
consume()
Method calculating consuming of device.boolean
isFree()
The method determines if the device is not occupied by any person.boolean
isRightDevice(Creature creature)
Checks if a person's desire matches the device's classification.boolean
isUsageLimit()
The method determines whether the use of this device by a specific person has expired.void
setState(AbstractActionDeviceState state)
Change device states.void
updateDuration()
Method that changes durationOfUsing.void
usage()
The method reduces the period of use of this device by a specific person.-
Methods inherited from class cz.cvut.fel.omo.SmartHome.devices.AbstractDevice
consumes, isBroken, isEntertaining, repairDevice
-
-
-
-
Field Detail
-
deviceClassification
protected ClassificationEnum deviceClassification
-
state
protected AbstractActionDeviceState state
-
durationOfUsing
private int durationOfUsing
-
-
Constructor Detail
-
AbstractActionDevice
public AbstractActionDevice(Floor floor, java.lang.String deviceName, int durationOfUsing, Consumption consumption)
-
-
Method Detail
-
action
public void action(Creature creature)
The method implemented by the state pattern. Depending on the state of the device, a different interaction of the device with a person is performed.- Parameters:
creature
- A person who interacts with device.
-
consume
public void consume()
Description copied from class:AbstractDevice
Method calculating consuming of device.- Specified by:
consume
in classAbstractDevice
-
isFree
public boolean isFree()
The method determines if the device is not occupied by any person.- Returns:
-
isRightDevice
public boolean isRightDevice(Creature creature)
Checks if a person's desire matches the device's classification.- Parameters:
creature
- person- Returns:
- true if it matches
-
setState
public void setState(AbstractActionDeviceState state)
Change device states.- Parameters:
state
-
-
usage
public void usage()
The method reduces the period of use of this device by a specific person.
-
isUsageLimit
public boolean isUsageLimit()
The method determines whether the use of this device by a specific person has expired.- Returns:
-
updateDuration
public void updateDuration()
Method that changes durationOfUsing. Help to simulate different times of using for different persons.
-
-