泡妞计划-java
来源:互联网 发布:python黑客编程 编辑:程序博客网 时间:2024/06/09 20:16
package com.qianfeng.day10.demo4;
public abstract class Plan {
privateGirl girl;//使用聚合(组合),本类中,声明了引用变量都算是聚合
privateBoy boy;//有引用属性时就用聚合,比如girl和boy
publicPlan(Girl girl, Boy boy){
this.girl = girl;
this.boy = boy;
}
public void chat(){
};
public void dinner(){
};
public void movie(){
};
public void shopping(){
};
public void forLove(){
};
publicGirl getGirl() {//属性私有化了,只能用setget方法访问
return girl;
}
publicvoid setGirl(Girl girl) {
this.girl = girl;
}
publicBoy getBoy() {
return boy;
}
publicvoid setBoy(Boy boy) {
this.boy = boy;
}
publicabstract void doPlan();
}
package com.qianfeng.day10.demo4;
public class Boy {
privateString name;
publicString getName() {
return name;
}
publicvoid setName(String name) {
this.name = name;
}
publicBoy(String name) {
this.name = name;
}
/*publicvoid chat() {
System.out.println("和" + this.getGirl().getName() +"一起聊天");
}
publicvoid movie() {
System.out.println("和" + this.getGirl().getName() +"看电影");
}
publicvoid shopping() {
System.out.println("和" + this.getGirl().getName() +"shopping");
}
publicvoid forLove() {
System.out.println("向" + this.getGirl().getName() +"表白");
}
publicvoid dinner() {
System.out.println("和" + this.getGirl().getName() +"烛光晚餐");
}*/
publicvoid paoNiu(Plan plan){
plan.doPlan();
}
}
package com.qianfeng.day10.demo4;
public class Girl {
privateString name;
publicString getName() {
return name;
}
publicvoid setName(String name) {
this.name = name;
}
publicGirl(String name){
this.name = name;
}
}
package com.qianfeng.day10.demo4;
public class PlanA extends Plan {
publicPlanA(Girl girl , Boy boy){
super(girl, boy);
}
public void chat(){
System.out.println(super.getBoy().getName()+ "跟" +
super.getGirl().getName()+ "暗送求波....");
};
public void forLove(){
/*System.out.println("可惜了," +super.getGirl().getName()
+ "要求,没有1000w身价,免谈~");*/
System.out.println("欧巴,我愿意~~");
};
@Override
publicvoid doPlan() {
chat();
forLove();
}
}
package com.qianfeng.day10.demo4;
public class PlanB extends Plan{
publicPlanB(Girl girl, Boy boy) {
super(girl, boy);
}
public void chat(){
System.out.println(super.getBoy().getName()+ "跟" +
super.getGirl().getName()+ "暗送求波....");
};
public void dinner(){
System.out.println(super.getBoy().getName()+"@"
+ super.getGirl().getName() + ":走,去吃猪脚饭...");
};
public void movie(){
System.out.println(super.getBoy().getName()+"@"
+ super.getGirl().getName() + ":看午夜凶铃去,别想歪了,我就想看恐怖片...");
};
public void forLove(){
System.out.println("不好意思,你是个好人~");
};
@Override
publicvoid doPlan() {
for(int i = 0; i < 4; i++){
chat();
dinner();
movie();
forLove();
}
}
}
package com.qianfeng.day10.demo4;
public class Test {
publicstatic void main(String[] args) {
/*Girl girl = new Girl("刘亦菲");
Boy boy = new Boy("隔壁老王");
boy.setGirl(girl); //泡妞对象
boy.chat();
boy.dinner();
Girl girl2 = new Girl("范冰冰");
boy.setGirl(girl2); //泡妞对象
boy.chat();
boy.dinner();*/
Girl girl = new Girl("罗玉凤");
Boy boy = new Boy("隔壁老王");
PlanA planA = new PlanA(girl, boy);
PlanB planB = new PlanB(girl, boy);
//boy.paoNiu(planA);
boy.paoNiu(planB);
}
}
- 泡妞计划-java
- linux-我的泡妞计划
- 泡妞
- 泡妞意境
- 泡妞字典
- 怎么泡妞
- 泡妞秘籍
- 泡妞技巧
- 泡妞经验
- 泡妞三部曲
- java计划
- 泡妞如此简单!!!
- 泡妞就是如此简单
- 男人泡妞的最高境界
- 前人泡妞必胜法
- 当代男人泡妞初级教程
- 当代男人泡妞初级教程
- 当代男人泡妞初级教程
- java--重写 final (课堂笔记)
- java-Object类(课堂)
- 女孩 鸟交互--java
- Eclipse+Pydev环境下使用utf-8编码
- 用 C# 实现带键值的优先队列
- 泡妞计划-java
- django orm总结
- apache安装完成之后,start出现了"the requested operation has failed !"
- 关于工作的一点总结和思考
- JS执行顺序
- 解决IScroll5超链接点击无效的问题
- Java 字符与字符串运算
- 通过网页打开App并传递参数
- AtomicStampedReference 与 AtomicInteger