lab5
This commit is contained in:
43
lab/lab5/Question7/Bird.java
Normal file
43
lab/lab5/Question7/Bird.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
|
||||
* Date: 2022-03-19
|
||||
* Description: This is the class of Bird.
|
||||
*/
|
||||
|
||||
public class Bird extends Animal {
|
||||
/**
|
||||
* Altitude of the bird.
|
||||
*/
|
||||
private double altitude;
|
||||
|
||||
/**
|
||||
* Constructor of Bird.
|
||||
*
|
||||
* @param name name of the bird
|
||||
* @param weight weight of the bird
|
||||
* @param altitude altitude of the bird
|
||||
*/
|
||||
public Bird(String name, double weight, double altitude) {
|
||||
super(name, weight);
|
||||
this.altitude = altitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the altitude of the bird.
|
||||
*
|
||||
* @return altitude of the bird
|
||||
*/
|
||||
public double getAltitude() {
|
||||
return altitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
public static void testBird() {
|
||||
Bird bird = new Bird("Bird", 1.0, 10.0);
|
||||
System.out.println(bird.getName() == "Bird");
|
||||
System.out.println(bird.getWeight() == 1.0);
|
||||
System.out.println(bird.getAltitude() == 10.0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user