//weatherState.java
public interface weatherState{
public void showState();
}
//cloudyLittleState.java
public class cloudyLittleState implements weatherState{
public void showState(){
System.out.println("少云,晴");
}
//cloudyDayState.java
public class cloudyDayState implements weatherState{
public void showState(){
System.out.println("多云,阴");
}
}
//sunnyDayState.java
public class sunnyDayState implements weatherState{
public void showState(){
System.out.println("晴天");
}
}
//weather.java
public class weather{
weatherState wS;
public void setWeatherState(weatherState wS){
this.wS=wS;
}
public void show(){
wS.showState();
}
}