China Naming Network - Auspicious day query - Java interface problem
Java interface problem
The company is working on a. net project now, and there is no Eclipse in the computer. I made it with a notepad. There may be a slight compilation error, fine-tune it yourself.
Interface weather conditions {
void showState();
}
Class weather {
WeatherState state = null
Public weather () {
}
Public Weather (Weather Status) (
this.state = state
}
Public display () {
state . show state();
}
}
Class Fine implements WeatherState {
Public void showState(){
system . out . println(" clear ");
}
}
Class Rain implements WeatherState {
Public void showState(){
system . out . println(" rain ");
}
}
Public class Main {
Public static void main(String[] args) {
WeatherState state 0 1 = new Fine();
WeatherState state 02 = new Rain();
Weather = new weather (state 01); //You can insert 0 1 or 02 in brackets.
weather.show()。
}
}