Score
0
Watch 25 Star 104 Fork 12

Gitee星球的小活动 / 第 0 届 代码编故事接力赛

Join us
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
让我们点燃程序员写作之魂,一人用代码写一段故事玩玩吧~ spread retract

Clone or download
java-StoryMountainTest 1.39 KB
Copy Edit Web IDE Raw Blame History
//编程语言:java
//故事主题:从前有座山……
public class StoryMountainTest {
public static void main(String[] args) {
System.out.println("相信大家都听过这么一个故事~");
Story story = new Story();
story.start();
}
}
/**
* 故事
*/
@Data
class Story {
public void start() {
System.out.println("从前有座山");
Mountain mountain = new Mountain();
System.out.println("山里有座庙");
Temple temple = new Temple();
mountain.setTemple(temple);
System.out.println("庙里有个老和尚和小和尚");
Monk old = new Monk(true);
Monk little = new Monk(false);
temple.setOld(old);
temple.setLittle(little);
System.out.println("老和尚对小和尚说:我给你讲个故事吧……\n");
old.sayStory(this);
}
}
/**
* 山
*/
@Data
class Mountain{
private Temple temple;
}
/**
* 庙
*/
@Data
class Temple{
private Monk old;
private Monk little;
}
/**
* 和尚
*/
@Data
class Monk{
//老和尚标记
private Boolean oldTag;
public Monk(Boolean oldTag) {
this.oldTag = oldTag;
}
public void sayStory(Story story){
if (oldTag) {
//老和尚才能讲故事
story.start();
}
}
}

Comment ( 1 )

Sign in for post a comment

1
https://gitee.com/Selected-Activities/Code-relay.git
git@gitee.com:Selected-Activities/Code-relay.git
Selected-Activities
Code-relay
第 0 届 代码编故事接力赛
master

Help Search

220309 7019f5b6 1899542 220318 4015cbb9 1899542