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();
        }
        
        
    
    }

  • 相关阅读:
    更改SQLServer实例默认字符集
    使用DMV排查数据库系统异常
    OD使用符号文件进行源码级调试问题
    申请博客园第一天
    各种mac软件地址
    第6条:理解“属性”
    提高代码质量的几个方法!52个,先罗列几个自己看
    Item2的使用
    MAC命令大全
    PV UV IP
  • 原文地址:https://www.cnblogs.com/HRZJ/p/5896793.html
Copyright © 2011-2022 走看看