编写Java应用程序,定义Animal类,此类中有动物的属性:名称 name,腿的数量legs,统计动物的数量 count;方法:设置动物腿数量的方法 void setLegs(),获得腿数量的方法 getLegs(),设置动物名称的方法 setKind(),获得动物名称的方法 getKind(),获得动物数量的方法 getCount().定义Fish类,是Animal类的子类,统计鱼的数量 count,获得鱼数量的方法 getCount().定义Tiger类,是Animal类的子类,统计老虎的…
package shape; public class Shape { //定义成员变量 private double zhouchang; private double mianji; public double getZhouchang() { return zhouchang; } public void setZhouchang(double zhouchang) { this.zhouchang = zhouchang; } public double getMianji() { re…
Account package com.hanqi.test; public class Account { private String zhanghao;private double yve; Account (String z,double c) { zhanghao=z; yve+=c; } Account (String z) { zhanghao=z; } void cunkuan(double c) { yve+=c; System.out.println("存款:"+c…
package zuoye8; public abstract class Shape { private double zhouchang ; private double mianji ; public Shape(double zhouchang, double mianji) { super(); this.zhouchang = zhouchang; this.mianji = mianji; } public Shape() { super(); } //抽象一个周长方法 publi…
编写Java应用程序.首先定义一个描述银行账户的Account类,包括成员变 量“账号”和“存款余额”,成员方法有“存款”.“取款”和“余额查询”.其次, 编写一个主类,在主类中测试Account类的功能. public class account { private String zhanghao; private double yue; account(String zh) { zhanghao=zh; } account(String zh,double ck) { zhanghao=zh…
package zuoye; public class Cat { String name="妮妮"; String color="灰色"; int age=1; void method() { System.out.println("姓名是:"+name); } void method2() { System.out.println("喵喵"); } } package zuoye; import java.util.Sca…
package com.hanqi.test; //银行账号 public class account { private String zhanghao;//账号 //私有余额 private double yue;//余额 //double cunkuan; // double qukuan; //构造方法= //有参无返 account(String zh) { zhanghao=zh; } account(String zh,double ck) { zhanghao=zh; yue+=…
package com.hanqi.test; public class xiyoujirenwu { private double height;// 身高 private String name;// 名称 private String weapon;// 武器 public double getHeight() { return height; } public void setHeight(double height) { if(height<=10) { System.out.prin…
package liu0917; public class Cat { String name="妮妮"; int age=2; String maose="灰色"; void mao() { System.out.println("cat的姓名是:"+name); } void hanjiao() { System.out.println("喵喵"); } } package liu0917; public class Ca…
package lianxi; public interface InterfaceA { void printCapitalLetter(); } package lianxi; public interface InterfaceB { void printLowercaseLetter(); } package lianxi; public class Print1 implements InterfaceA, InterfaceB { @Override public void prin…
i汽车类 package com.lanxi.demo2_3; public class Car { private String name; private int price; @Override//重写toString方法 public String toString() { return "Car [name=" + name + ", price=" + price + "]"; } public Car() {//创建无参构造方法 s…
package b; public interface CanFly { public void fly(); } package b; public class FeiJi implements CanFly { @Override public void fly() { System.out.println("飞机 化工能源飞行"); } } package b; public class Niao implements CanFly { @Override public void…