Added state pattern sample

This commit is contained in:
Ilkka Seppala
2014-08-23 08:47:44 +03:00
parent b3d48cc4df
commit 9166d47ffc
7 changed files with 123 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
package com.iluwatar;
public class PeacefulState implements State {
private Mammoth mammoth;
public PeacefulState(Mammoth mammoth) {
this.mammoth = mammoth;
}
@Override
public void observe() {
System.out.println(String.format("%s is calm and peaceful.", mammoth));
}
@Override
public void onEnterState() {
System.out.println(String.format("%s calms down.", mammoth));
}
}