parent
82a61019bc
commit
8cf0be49ed
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/thirdTest2.iml" filepath="$PROJECT_DIR$/thirdTest2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,48 @@
|
||||
interface WeatherState{
|
||||
void showState();
|
||||
}
|
||||
class sunday implements WeatherState{
|
||||
@Override
|
||||
public void showState() {
|
||||
System.out.println("今天是个大晴天!");
|
||||
}
|
||||
}
|
||||
class cloudy implements WeatherState{
|
||||
public void showState() {
|
||||
System.out.println("今天是多云或者阴天!");
|
||||
}
|
||||
}
|
||||
class rainy implements WeatherState{
|
||||
public void showState() {
|
||||
System.out.println("今天会下雨!");
|
||||
}
|
||||
}
|
||||
class snowy implements WeatherState{
|
||||
public void showState() {
|
||||
System.out.println("今天会下雪!");
|
||||
}
|
||||
}
|
||||
class Weather{
|
||||
WeatherState state;
|
||||
public Weather(WeatherState state){
|
||||
this.state=state;
|
||||
}
|
||||
public void show(){
|
||||
state.showState();
|
||||
}
|
||||
}
|
||||
public class Main {
|
||||
public static void testTrial(){
|
||||
Weather weather = new Weather(new sunday());
|
||||
weather.show();
|
||||
weather = new Weather(new cloudy());
|
||||
weather.show();
|
||||
weather = new Weather(new rainy());
|
||||
weather.show();
|
||||
weather = new Weather(new snowy());
|
||||
weather.show();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
testTrial();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in new issue