Formatted all files to the same standard

This commit is contained in:
matthew
2014-10-08 13:42:12 +01:00
parent 53a2a8b150
commit 3da9ad5469
151 changed files with 952 additions and 870 deletions

View File

@ -7,7 +7,7 @@ public class AngryState implements State {
public AngryState(Mammoth mammoth) {
this.mammoth = mammoth;
}
@Override
public void observe() {
System.out.println(String.format("%s is furious!", mammoth));

View File

@ -1,22 +1,22 @@
package com.iluwatar;
/**
*
*
* In State pattern the object (Mammoth) has internal state object (State) that
* defines the current behavior. The state object can be changed to alter the
* behavior.
*
*
*/
public class App {
public static void main(String[] args) {
public static void main(String[] args) {
Mammoth mammoth = new Mammoth();
mammoth.observe();
mammoth.timePasses();
mammoth.observe();
mammoth.timePasses();
mammoth.observe();
Mammoth mammoth = new Mammoth();
mammoth.observe();
mammoth.timePasses();
mammoth.observe();
mammoth.timePasses();
mammoth.observe();
}
}
}

View File

@ -3,16 +3,16 @@ package com.iluwatar;
/**
*
* Mammoth has internal state that defines its behavior.
*
*
*/
public class Mammoth {
private State state;
public Mammoth() {
state = new PeacefulState(this);
}
public void timePasses() {
if (state.getClass().equals(PeacefulState.class)) {
changeStateTo(new AngryState(this));
@ -25,12 +25,12 @@ public class Mammoth {
this.state = newState;
this.state.onEnterState();
}
@Override
public String toString() {
return "The mammoth";
}
public void observe() {
this.state.observe();
}

View File

@ -1,7 +1,7 @@
package com.iluwatar;
public class PeacefulState implements State {
private Mammoth mammoth;
public PeacefulState(Mammoth mammoth) {
@ -17,5 +17,5 @@ public class PeacefulState implements State {
public void onEnterState() {
System.out.println(String.format("%s calms down.", mammoth));
}
}

View File

@ -3,12 +3,12 @@ package com.iluwatar;
/**
*
* State interface.
*
*
*/
public interface State {
void onEnterState();
void observe();
}