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

  • 相关阅读:
    W3C标准
    Oracle数据库中的几个名字及监听的配置问题
    Linux中特别要注意用户与文件权限的问题
    Linux中mv重命名作用及打包war压缩文件及分配权限
    虚拟机的ip网络设置的选择
    sqlplus中登陆账户用@加上数据库sid
    bat文件从@含义起
    我原来还在这
    Hibernate的数据操作(4.*以上版本)
    Hibernate中的配置文件
  • 原文地址:https://www.cnblogs.com/HRZJ/p/5896793.html
Copyright © 2011-2022 走看看