用Java写个MM,写着玩的,纯属娱乐。
2010-11-24 21:42 jinze 阅读(629) 评论(0) 编辑 收藏 举报用Java写个MM,写着玩的,纯属娱乐。
import java.util.Scanner;
public class girl {
private String Name = null;
private int Height = 0;
private int weight = 0;
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public int getHeight() {
return Height;
}
public void setHeight(int height) {
Height = height;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public void ShowMe(){
System.out.println("您好,主人");
System.out.println("我的名字是"+this.Name);
System.out.println("我的身高是"+this.Height);
System.out.println("我的体重是"+this.weight);
}
public static void main(String[] args) {
girl MM = new girl();
MM.setName("林志玲");
MM.setHeight(177);
MM.setWeight(55);
System.out.println("身高" + MM.getHeight() + "cm");
System.out.println("体重" + MM.getWeight() + "Kg");
System.out.println("还满意吗?Y/N");
Scanner scanner = new Scanner(System.in);
String ste = scanner.next();
if (ste.toLowerCase().equals("y")) {
System.out.println("这个美美送给你了!");
}
if (ste.toLowerCase().equals("n")) {
System.out.println("您希望的身高是:(cm)");
try {
int h = java.lang.Integer.parseInt(scanner.next());
MM.setHeight(h);
} catch (Exception ex) {
System.out.println("这个身高似乎不合规范啊,系统思考中。。。。");
}
System.out.println("您希望的体重是:(KG)");
try {
int h = java.lang.Integer.parseInt(scanner.next());
MM.setWeight(h);
} catch (Exception ex) {
System.out.println("这个体重似乎不合规范啊,系统思考中。。。。");
}
System.out.println("最后一个问题,您希望他叫什么呢?");
MM.setName(scanner.next());
MM.ShowMe();
System.out.println("Good Luck!");
}
else{
System.out.println("阁下,您该吃药了。");
}
}
}