zoukankan      html  css  js  c++  java
  • 创建如下三个类:(People类中的三个方法分别输出一些信息,ChinaPeople 和AmericanPeople类重写父类的三个方法)。

    package People;
    
    public class People 
    {
        protected double height;
        protected double weight;
        
        
        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 void speakHello()
        {
            
        }
        public void averangeHeight()
        {
            
        }
        public void averangeWeight()
        {
            
        }
        
    }
    package People;
    
    public class ChinesePeople extends People
    {
         public void speakHello()
            {
                System.out.println("你好,我来自中国,我的身高是:"+this.height+"我的体重是:"+this.weight);
            }
            public void averangeHeight()
            {
                System.out.println("我们中国人的平均身高是1.70米");
            }
            public void averangeWeight()
            {
                System.out.println("我们中国人的平均体重是55kg米");
            }
            public void chineseKongfu()
            {
                System.out.println("我会中国功夫--太极拳,借力用力,以慢打快。");
            }
    }
    package People;
    
    public class AmericanPeople extends People
    {
        public void speakHello()
        {
            System.out.println("你好,我来自美国,我的身高是:"+this.height+"我的体重是:"+this.weight);
        }
        public void averangeHeight()
        {
            System.out.println("我们美国人的平均身高是1.72米");
        }
        public void averangeWeight()
        {
            System.out.println("我们美国人人的平均体重是75kg米");
        }
        public void icanBoxing()
        {
            System.out.println("我会拳击,左勾拳,右勾拳,哈哈哈");
        }
    }
    package People;
    
    public class TEXT_people 
    {
    
        public static void main(String[] args)
        {
            ChinesePeople cp=new ChinesePeople();
            cp.setHeight(168);
            cp.setWeight(65);
            cp.speakHello();
            cp.averangeHeight();
            cp.averangeWeight();
            cp.chineseKongfu();
            
            AmericanPeople ap=new AmericanPeople();
            ap.setHeight(155);
            ap.setWeight(55);
            ap.speakHello();
            ap.averangeHeight();
            ap.averangeWeight();
            ap.icanBoxing();
        }
        
        
    
    }

  • 相关阅读:
    hdu1542线段树+离散化+扫描线
    Codeforces Round #373 (Div. 2)
    Codeforces Round #381 (Div. 2)
    Codeforces Round #352 (Div. 2)
    CodeForces
    poj3311 状压dp+floyd
    CodeForces 385 D.Bear and Floodlight 状压DP
    Codeforces Round #299 (Div. 2)D. Tavas and Malekas
    Tavas and Karafs 二分+结论
    ThikPHP3.1 常用方法(one)
  • 原文地址:https://www.cnblogs.com/HRZJ/p/5896793.html
Copyright © 2011-2022 走看看