• 19.创建如下三个类:(People类中的三个方法分别输出一些信息,ChinaPeople 和AmericanPeople类重写父类的三个方法)。


    package zuoye2;
    
    public class People 
    {
    	protected double height;
    	protected double weight;
    	private String guojia;
    	
    	public double getHeight() {
    		return height;
    	}
    	public void setHeight(double height) {
    		this.height = height;
    	}
    	public double getWeight() {
    		return weight;
    	}
    	public void setWeight(double weight) {
    		this.weight = weight;
    	}
    	public String getGuojia() {
    		return guojia;
    	}
    	public void setGuojia(String guojia) {
    		this.guojia = guojia;
    	}
    	
    	
    	public People() {
    		super();
    	}
    	public People(double height, double weight) {
    		super();
    		this.height = height;
    		this.weight = weight;
    	}
    	
    	public  void speackHello()
    	{
    		System.out.println("Hello");
    	}
    	public  void averageHeight()
    	{
    		System.out.println("平均身高是:");
    	}
    	public  void averageweight()
    	{
    		System.out.println("平均体重是:");
    	}
    
    }
    

      

    package zuoye2;
    
    public class ChinaPeople extends People {
    	
    	
    	public void chinaGongfu()
    	{
    		System.out.println("坐如钟,站如松,行如风,睡如弓");
    	}
    	public  void speackHello()
    	{
    		System.out.println("你好");
    	}
    
    }
    

      

    package zuoye2;
    
    public class AmericanPeople extends People {
    
    	
    	public void americanBoxing()
    	{
    		System.out.println("直拳,勾拳");
    	}
    }
    

      

    package zuoye2;
    
    public class Ceshi_people {
    
    	public static void main(String[] args) {
    
    
    		ChinaPeople c=new ChinaPeople();
    		
    		c.setHeight(180.0);
    		c.setWeight(70.0);
    		c.setGuojia("中国");
    		c.speackHello();
    		System.out.println(c.getGuojia());
    		c.averageHeight();System.out.println(c.getHeight());
    		c.chinaGongfu();
    		
    		System.out.println("");
    		
    		AmericanPeople a=new AmericanPeople();
    		a.setHeight(175.0);
    		a.setWeight(80.0);
    		a.setGuojia("美国佬");
    		a.speackHello();
    		System.out.println(a.getGuojia());
    		a.averageHeight();
    		System.out.println(a.getHeight());
    		a.averageweight();
    		System.out.println(a.getWeight());
    		a.americanBoxing();
    		
    		
    
    	}
    
    }
    

      

  • 相关阅读:
    BZOJ 1911: [Apio2010]特别行动队
    BZOJ 1096: [ZJOI2007]仓库建设(动态规划+斜率优化)
    BZOJ 2243: [SDOI2011]染色(树链剖分)
    BZOJ 1834: [ZJOI2010]network 网络扩容(网络流+费用流)
    BZOJ 1036: [ZJOI2008]树的统计Count(树链剖分)
    BZOJ 1875: [SDOI2009]HH去散步(矩阵乘法)
    BZOJ 1898: [Zjoi2004]Swamp 沼泽鳄鱼(矩阵乘法)
    BZOJ 2463: [中山市选2009]谁能赢呢?(博弈论)
    BZOJ 2879: [Noi2012]美食节
    BZOJ 1070: [SCOI2007]修车(费用流)
  • 原文地址:https://www.cnblogs.com/liuyanzeng/p/5894078.html
Copyright © 2020-2023  润新知