Added code comments.
This commit is contained in:
		| @@ -1,5 +1,20 @@ | |||||||
| package com.iluwatar; | 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 class App { | ||||||
| 	 | 	 | ||||||
|     public static void main( String[] args ) { |     public static void main( String[] args ) { | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| package com.iluwatar; | package com.iluwatar; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  | ||||||
|  |  * Fatigue enumeration | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| public enum Fatigue { | public enum Fatigue { | ||||||
|  |  | ||||||
| 	ALERT("alert"), TIRED("tired"), SLEEPING("sleeping"); | 	ALERT("alert"), TIRED("tired"), SLEEPING("sleeping"); | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| package com.iluwatar; | package com.iluwatar; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  | ||||||
|  |  * GiantController can update the giant data and redraw it using the view. | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| public class GiantController { | public class GiantController { | ||||||
|  |  | ||||||
| 	private GiantModel giant; | 	private GiantModel giant; | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| package com.iluwatar; | package com.iluwatar; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  | ||||||
|  |  * GiantModel contains the giant data | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| public class GiantModel { | public class GiantModel { | ||||||
| 	 | 	 | ||||||
| 	private Health health; | 	private Health health; | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| package com.iluwatar; | package com.iluwatar; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  | ||||||
|  |  * GiantView displays the giant | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| public class GiantView { | public class GiantView { | ||||||
|  |  | ||||||
| 	public void displayGiant(GiantModel giant) { | 	public void displayGiant(GiantModel giant) { | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| package com.iluwatar; | package com.iluwatar; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  | ||||||
|  |  * Health enumeration | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| public enum Health { | public enum Health { | ||||||
| 	 | 	 | ||||||
| 	HEALTHY("healthy"), WOUNDED("wounded"), DEAD("dead"); | 	HEALTHY("healthy"), WOUNDED("wounded"), DEAD("dead"); | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| package com.iluwatar; | package com.iluwatar; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  | ||||||
|  |  * Nourishment enumeration | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| public enum Nourishment { | public enum Nourishment { | ||||||
|  |  | ||||||
| 	SATURATED("saturated"), HUNGRY("hungry"), STARVING("starving"); | 	SATURATED("saturated"), HUNGRY("hungry"), STARVING("starving"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user