“我想找个女朋友”的那哥么,我给你创建了一个女友,请查收

禅心诡道 发布于 2014/06/09 10:16
阅读 6K+
收藏 8


package com.dp.create.builder;

public class GirlFriend {
	private final float hight; //身高
	private String skin; //肤色
	private float[] bwh; //三围
	private String education ;
	
	private GirlFriend(GirlFriendBuilder builder){
		this.hight = builder.hight;
		this.bwh = builder.bwh;
		this.education = builder.education;
		this.skin = builder.skin;
	}

	public String getSkin() {
		return skin;
	}

	public float getHight() {
		return hight;
	}

	public float[] getBwh() {
		return bwh;
	}
	
	public String getEducation() {
		return education;
	}
	
	@Override
	public String toString() {
		return "My GirlFriend is "+hight+"cm hight ,bwh is "+bwh[0]+","+bwh[1]+","+bwh[2]+",her skin color is "+skin+" and she is "+education;
	}
	public static class GirlFriendBuilder{
		private final float hight; //身高
		private String skin; //肤色
		private float[] bwh; //三围
		private String education;
		
		public GirlFriendBuilder(float hight){
			this.hight = hight;
		}
		
		public GirlFriendBuilder skin(String skin){
			this.skin = skin;
			return this;
		}
		
		public GirlFriendBuilder bwh(float bust,float waist,float hips){
			this.bwh = new float[]{bust,waist,hips};
			return this;
		}
		public GirlFriendBuilder education(String education){
			this.education = education;
			return this;
		}
		
		public GirlFriend GiveMeGirlFriend(){
			GirlFriend girlFriend = new GirlFriend(this);
			if(girlFriend.hight<160){
				throw new IllegalStateException("身高不足,不是女神");
			}
			if(girlFriend.hight>180){
				throw new IllegalStateException("身高太高,你hold不住");
			}
			if(girlFriend.skin == null){
				throw new NullPointerException("肤色未设定,不是白富美");
			}
			return girlFriend;
		}
	}
}


package com.dp.create.builder;

public class GF_app {
	public static void main(String[] args) {
		GirlFriend gf = new GirlFriend.GirlFriendBuilder(169.2f)
				.bwh(100f, 100f, 100f).skin("black").education("college student").GiveMeGirlFriend();
		System.out.println(gf);
	}
}



加载中
1
酷酷的就
酷酷的就

bwh(100f, 100f, 100f). 

尼特么的这是火腿肠么?

1
梅开源
梅开源

通过图灵测试了吗?

根据图灵测试,蒙着一块布去x,不知道x的是人还是机器,则说明此机器用户体验人工智能一个字好


梅开源
梅开源
回复 @ChanneW : if(checkUserId()=='。。。。'){ //按照祖先们的法子可以的 integer highLevel= Super.xx(); //todo: 根据highLevel调用不同叫声 }
CheneyWong
CheneyWong
可是没有提供被 x 的方法啊,请楼主赶快完善.
神州浪子
神州浪子
哈哈笑死我了
0
0
囧大爷
囧大爷

这位兄弟是有多急冻啊,兄弟们赶紧给介绍啊...

0
18号
18号
哥,你忒TM耿直
请喊我大龙哥
请喊我大龙哥
回复 @禅心诡道 : 的确是为人民币服务
禅心诡道
禅心诡道
为人民币服务
0
whaon
whaon
求原帖
禅心诡道
禅心诡道
http://www.oschina.net/question/1016595_157787
0
0
0
小魔仙
小魔仙
哈哈,谁说程序猿不懂浪漫
返回顶部
顶部