Java-中国人,北京人和美国人

public class People {
	protected double weight,height;
	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 americamBoxing(){
		System.out.println("直拳,勾拳,组合拳");
	}

}




public class Example {
	public static void main(String args[]){
		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.americamBoxing();
		beijingPeople.beijingOpera();
		beijingPeople.chinaGongfu();
		}
}




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

}


你可能感兴趣的:(Java-中国人,北京人和美国人)