1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
public class BugBirth {
public static void main(String[] args) { Insect insect = new Insect(); insect.setYear("1945年"); insect.setName("小小虫"); insect.fly("胡乱地飞"); insect.fly("边飞边唱:亲爱的你慢慢飞,小心前面带刺的玫瑰。。。"); insect.damage("破坏继电器,把自己也夹在了触点中间");
WomMan womMan = new WomMan(); womMan.setName("葛丽丝·霍波"); womMan.say("哦,我的上帝!我这么完美的程序,为什么不运行了?");
womMan.say("我的上帝!有一只小强!!"); insect.setName("特别丑的小强"); womMan.gentleTouch(999);
insect.die("特别丑的小强在霍波温柔的抚摸之下,最终壮烈牺牲了");
womMan.say("都是你的错,轻易伤害我,让我不知不觉地中了狂"); womMan.say("为了警醒后来猿,我就给你起名叫“bug”!"); womMan.say("我“温柔的抚摸”行为就叫“debug”。"); insect.setName("bug");
System.out.println("第一代bug就此诞生,也就此陨落。。"); }
}
class Insect {
private String year;
private String name;
public void damage(String something) { System.out.println(something); }
public void fly(String something) { System.out.println(something); }
public void die(String something) { System.out.println(something); }
public String getYear() { return year; }
public void setYear(String year) { this.year = year; }
public String getName() { return name; }
public void setName(String name) { this.name = name; } }
class WomMan {
private String name;
public void gentleTouch(int level) { for (int i = 0; i < level; i++) { System.out.println(name + ":用脚踩第" + (i + 1) + "次;"); } }
public void say(String something) { System.out.println(something); }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
|