people05-1——中国人、北京人和美国人

/* 

* Copyright (c) 2013, 烟台大学计算机学院 

* All rights reserved.

* 文件名称: people05-1——中国人、北京人和美国人

* 作    者:孙红蕾  

* 完成日期:2013 年 10 月 13 日 

* 问题描述:编写程序模拟中国人、美国人是人,北京人是中国人。除主类外,程序中有4个类:People,ChinaPeople,AmericanPeople和BeijingPeople类。

* 输入描述: 无

* 程序输出:  显示Test中的指令。

* 算法设计:略 

*/  

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ChinaPeople chinaPeople=new ChinaPeople();
		AmericanPeople americanPeople=new AmericanPeople();
		BeijingPeople beijingPeople=new BeijingPeople();
		chinaPeople.speakHello();
		americanPeople.speakHello();
		beijingPeople.speakHello();
		chinaPeople.averageHeight();
		americanPeople.averageHeight();
		beijingPeople.averageHeight();
		chinaPeople.averageWeight();
		americanPeople.averageWeight();
		beijingPeople.averageWeight();
		chinaPeople.chinaGongfu();
		americanPeople.americanBoxing();
		beijingPeople.beijingOpera();
		beijingPeople.chinaGongfu();
	}

}
public class People {
	protected double height,weight;
	public void speakHello(){
		System.out.println("yayayaya");
	}
	public void averageHeight(){
		height=173;
		System.out.println("average height:"+height);
	}
	public void averageWeight(){
		weight=70;
		System.out.println("average weight:"+weight);
	}
}


public class ChinaPeople extends People{
	public void speakHello(){
		System.out.println("您好");
	}
	public void averageHeight(){
		height=168.78;
		System.out.println("中国人的平均身高:"+height+"厘米");
	}
	public void averageWeight(){
		weight=65;
		System.out.println("中国人的平均体重:"+weight+"千克");
	}
	public void chinaGongfu(){
		System.out.println("坐如钟,站如松,睡如弓");
	}
}


public class AmericanPeople extends People{
	public void speakHello(){
		System.out.println("How do you do");
	}
	public void averageHeight(){
		height=176;
		System.out.println("American's average height:"+height+"cm");
	}
	public void averageWeight(){
		weight=75;
		System.out.println("American's average weight:"+weight+"kg");
	}
	public void americanBoxing(){
		System.out.println("直拳、勾拳、组合拳");
	}
}


public class BeijingPeople extends ChinaPeople{
	public void averageHeight(){
		height=172.5;
		System.out.println("中国人的平均身高:"+height+"厘米");
	}
	public void averageWeight(){
		weight=70;
		System.out.println("中国人的平均体重:"+weight+"千克");
	}
	void beijingOpera(){
		System.out.println("花脸、青衣、花旦和老生");
	}
}



你可能感兴趣的:(people05-1——中国人、北京人和美国人)