Java实验题3_4_林大锐格平台
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java实验题3_4_林大锐格平台相关的知识,希望对你有一定的参考价值。
import java.util.Scanner; abstract class Animal { public String name; public int age; public float weight; public void showInfo() { System.out.println("name:" + this.name + " age:" + this.age + " weight:" + this.weight); } public abstract void move(); public abstract void eat(); } class Bird extends Animal { Bird(String a,int b,float c){ this.name=a; this.age=b; this.weight=c; } public void showInfo() { System.out.println("name:" + this.name + " age:" + this.age + " weight:" + this.weight); } public void move(){ System.out.println(name+" Fly"); } public void eat(){ System.out.println(name+" Eat insects"); } //write your own codes } public class Main { public static void main(String[] args) { String name; int age; float weight; Scanner scanner = new Scanner(System.in); name = scanner.next(); age = scanner.nextInt(); weight = scanner.nextFloat(); //write your own codes Bird bir = new Bird(name,age,weight); bir.showInfo(); bir.move(); bir.eat(); } }
************************************************************************************
注意,子类中的变量重新申明的话会隐藏父类中的变量;
以上是关于Java实验题3_4_林大锐格平台的主要内容,如果未能解决你的问题,请参考以下文章