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

    package zhongqiuzuoye;
    
    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 averageHeight()
        {
        }
        public void averageWeight()
        {        
        }
    
    }
    package zhongqiuzuoye;
    
    public class ChinaPeople extends People{
        public void chinaGoufu()
        {
            System.out.println("坐如钟,站如松");
        }
        public void speakHello()
        {
            System.out.println("你好");
        }
        public void averageHeight()
        {
            System.out.println("中国人平均身高为170cm");
        }
        public void averageWeight()
        {
            System.out.println("中国人平均体重是70kg");
        }
    
        
    
    }
    package zhongqiuzuoye;
    
    public class AmericnPeople extends People{
        public void chinaGoufu()
        {
            System.out.println("直拳");
        }    
        public void speakHello()
        {
            System.out.println("hello");
        }
        public void averageHeight()
        {
            System.out.println("美国人平均身高为180cm");
        }
        public void averageWeight()
        {
            System.out.println("美国人平均体重是80kg");
        }
    
    }
    package zhongqiuzuoye;
    
    public class TestPeople {
        
        public static void main(String[] args) {
            
            ChinaPeople c =new ChinaPeople();
            c.speakHello();
            c.averageHeight();
            c.averageWeight();
            
            AmericnPeople a=new AmericnPeople();
            a.speakHello();
            a.averageHeight();
            a.averageWeight();
    
    
    }
    }

  • 相关阅读:
    JaunsGraph数据模型
    JanusGraph的schema及数据建模
    JanusGraph Server配置
    JanusGraph与Cassandra集成模式
    cassandra的primary key, partition key, cluster key,
    Predix Asset Service深度分析
    Predix中模型设计
    web工程中web.xml元素加载顺序以及配置实例
    Tomcat,Jboss,Glassfish等web容器比较选型
    intelliJ idea像eclipse一样在class中断点调试
  • 原文地址:https://www.cnblogs.com/zs6666/p/5898351.html
Copyright © 2011-2022 走看看