mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 08:59:01 +00:00
40 lines
688 B
Java
40 lines
688 B
Java
package com.iluwatar.servant;
|
|
|
|
/**
|
|
*
|
|
* King
|
|
*
|
|
*/
|
|
public class King implements Royalty {
|
|
|
|
private boolean isDrunk;
|
|
private boolean isHungry = true;
|
|
private boolean isHappy;
|
|
private boolean complimentReceived;
|
|
|
|
@Override
|
|
public void getFed() {
|
|
isHungry = false;
|
|
}
|
|
|
|
@Override
|
|
public void getDrink() {
|
|
isDrunk = true;
|
|
}
|
|
|
|
public void receiveCompliments() {
|
|
complimentReceived = true;
|
|
}
|
|
|
|
@Override
|
|
public void changeMood() {
|
|
if (!isHungry && isDrunk) isHappy = true;
|
|
if (complimentReceived) isHappy = false;
|
|
}
|
|
|
|
@Override
|
|
public boolean getMood() {
|
|
return isHappy;
|
|
}
|
|
}
|