zoukankan      html  css  js  c++  java
  • 3. 编写Java应用程序,定义Animal类,此类中有动物的属性:名称 name,腿的数量legs,统计动物的数量 count;方法:设置动物腿数量的方法 void setLegs(),获得腿数量的方法 getLegs(),设置动物名称的方法 setKind(),获得动物名称的方法 getKind(),获得动物数量的方法 getCount()。定义Fish类,是Animal类的子类,统计鱼的数量

    //Animal 类
    package d922B;

    public class Animal {
    private String kind;
    private int legs,count;
    public String getKind() {
    return kind;
    }
    public void setKind(String kind) {
    this.kind = kind;
    }
    public int getLegs() {
    return legs;
    }
    public void setLegs(int legs) {
    this.legs = legs;
    }
    public int getCount() {
    return count;
    }
    public void setCount(int count) {
    this.count = count;
    }

    }
    //Fish类
    package d922B;

    public class Fish extends Animal {
    private int count;

    public int getCount() {
    	return count;
    }
    
    public void setCount(int count) {
    	this.count = count;
    }
    

    }
    //Tiger类
    package d922B;

    public class Tiger extends Animal {
    private int count;

    public int getCount() {
    	return count;
    }
    
    public void setCount(int count) {
    	this.count = count;
    }
    

    }

  • 相关阅读:
    五彩珠游戏
    repeater 的编辑功能
    客户端禁止cokice后,对session的影响.
    IIS无法运行ASP程序?
    winXP 密码 破解 重置
    winXP 密码 破解 重置
    IIS无法运行ASP程序?
    winXP 密码 破解 重置
    winXP 密码 破解 重置
    1.大批量数据操作
  • 原文地址:https://www.cnblogs.com/nicebaby/p/5901412.html
Copyright © 2011-2022 走看看