mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 18:59:10 +00:00
Adding Servant Design pattern classes
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.iluwatar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Servant {
|
||||
public String name;
|
||||
|
||||
public Servant(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void feed(Royalty r){
|
||||
r.feed();
|
||||
}
|
||||
|
||||
public void giveWine(Royalty r){
|
||||
r.giveDrink();
|
||||
}
|
||||
|
||||
public void GiveCompliments(Royalty r){
|
||||
r.receiveCompliments();
|
||||
}
|
||||
|
||||
public boolean checkIfYouWillBeHanged(ArrayList<Royalty> tableGuests){
|
||||
boolean anotherDay = true;
|
||||
for( Royalty r : tableGuests )
|
||||
if( !r.getMood() ) anotherDay = false;
|
||||
|
||||
return anotherDay;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user