Files
oop/lab/lab7/Question8/Ostrich.java
2022-04-03 15:15:13 +08:00

39 lines
730 B
Java

/*
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
* Date: 2022/04/03
* Description: This is the class of Ostrich, which is a child class of Bird.
*/
public class Ostrich extends Bird {
/**
* Constructor. Ostrich always has 10 eggs.
*
* @param name
*/
public Ostrich(String name) {
super(name, 10);
}
/**
* Ostrich can not fly.
*
* @return false
*/
@Override
public boolean canFly() {
return false;
}
/**
* Test.
*/
public static void testOstrich() {
Ostrich o1 = new Ostrich("Ostrich1");
System.out.println(o1.canFly() == false);
System.out.println(o1.getName() == "Ostrich1");
System.out.println(o1.getNumOfEggs() == 10);
System.out.println(o1.getLegs() == 2);
}
}