mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 10:58:51 +00:00
Completed MVC example code.
This commit is contained in:
@@ -3,6 +3,17 @@ package com.iluwatar;
|
||||
public class App {
|
||||
|
||||
public static void main( String[] args ) {
|
||||
System.out.println( "Hello World!" );
|
||||
// create model, view and controller
|
||||
GiantModel giant = new GiantModel(Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
GiantView view = new GiantView();
|
||||
GiantController controller = new GiantController(giant, view);
|
||||
// initial display
|
||||
controller.updateView();
|
||||
// controller receives some interactions that affect the giant
|
||||
controller.setHealth(Health.WOUNDED);
|
||||
controller.setNourishment(Nourishment.HUNGRY);
|
||||
controller.setFatigue(Fatigue.TIRED);
|
||||
// redisplay
|
||||
controller.updateView();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user