Traditional Culture Encyclopedia - Weather inquiry - 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()。
}
}
- Previous article:Aesthetic sentences of vernal equinox
- Next article:X-men character introduction
- Related articles
- When is the best time to go to the Sichuan-Tibet line? 3 18 self-driving guide
- What is the average daily temperature in Xi 'an every year in 65438+ 10 and 65438+February, and what are the highest and lowest temperatures respectively? Thank you very much.
- Weather conditions in Bohai Sea and Yellow Sea on June 2, 20 15
- Is it always cloudy and cold in Germany?
- From north to south to Dali
- Urgent for the introduction of natural disasters in Denmark! ! !
- How about Linshui Jingping Diagonal Agricultural Development Co., Ltd.?
- How to adjust the abnormal sound of wiper?
- Selected [5] model articles of press releases
- What are some weather-related idioms?