Added code comments.
This commit is contained in:
parent
3bcca7102c
commit
b01e841dff
@ -1,5 +1,20 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* Model-View-Controller is a pattern for implementing user interfaces. It divides the application
|
||||
* into three interconnected parts namely the model, the view and the controller.
|
||||
*
|
||||
* The central component of MVC, the model, captures the behavior of the application in terms of its problem
|
||||
* domain, independent of the user interface. The model directly manages the data, logic and rules of the
|
||||
* application. A view can be any output representation of information, such as a chart or a diagram
|
||||
* The third part, the controller, accepts input and converts it to commands for the model or view.
|
||||
*
|
||||
* In this example we have a giant (GiantModel) with statuses for health, fatigue and nourishment. GiantView
|
||||
* can display the giant with its current status. GiantController receives input affecting the model and
|
||||
* delegates redrawing the giant to the view.
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
public static void main( String[] args ) {
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* Fatigue enumeration
|
||||
*
|
||||
*/
|
||||
public enum Fatigue {
|
||||
|
||||
ALERT("alert"), TIRED("tired"), SLEEPING("sleeping");
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* GiantController can update the giant data and redraw it using the view.
|
||||
*
|
||||
*/
|
||||
public class GiantController {
|
||||
|
||||
private GiantModel giant;
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* GiantModel contains the giant data
|
||||
*
|
||||
*/
|
||||
public class GiantModel {
|
||||
|
||||
private Health health;
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* GiantView displays the giant
|
||||
*
|
||||
*/
|
||||
public class GiantView {
|
||||
|
||||
public void displayGiant(GiantModel giant) {
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* Health enumeration
|
||||
*
|
||||
*/
|
||||
public enum Health {
|
||||
|
||||
HEALTHY("healthy"), WOUNDED("wounded"), DEAD("dead");
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* Nourishment enumeration
|
||||
*
|
||||
*/
|
||||
public enum Nourishment {
|
||||
|
||||
SATURATED("saturated"), HUNGRY("hungry"), STARVING("starving");
|
||||
|
Loading…
x
Reference in New Issue
Block a user