mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-13 22:16:03 +00:00
Improved comments for state pattern.
This commit is contained in:
1 parent
742f8376b3
commit
27a27594f4
3 files changed
+13
-1
No files matched your search
@@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Angry state.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AngryState implements State {
|
public class AngryState implements State {
|
||||||
|
|
||||||
private Mammoth mammoth;
|
private Mammoth mammoth;
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package com.iluwatar;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* In State pattern the object (Mammoth) has internal state object (State) that
|
* In State pattern the container object (Mammoth) has an internal state object (State) that
|
||||||
* defines the current behavior. The state object can be changed to alter the
|
* defines the current behavior. The state object can be changed to alter the
|
||||||
* behavior.
|
* behavior.
|
||||||
*
|
*
|
||||||
|
* In this example the mammoth changes its behavior as time passes by.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Peaceful state.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class PeacefulState implements State {
|
public class PeacefulState implements State {
|
||||||
|
|
||||||
private Mammoth mammoth;
|
private Mammoth mammoth;
|
||||||
|
|||||||
Reference in new issue
Block a user