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

48 lines
730 B
Java

/*
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
* Date: 2022/04/03
* Description: This is the class of Dog. Dog has 4 legs and can not fly.
*/
public class Dog extends Animal {
/**
* Constructor of Dog.
*
* @param name String
*/
public Dog(String name) {
super(name);
}
/**
* Dog has 4 legs.
*
* @return int
*/
@Override
public int getLegs() {
return 4;
}
/**
* Dog can not fly.
*
* @return boolean
*/
@Override
public boolean canFly() {
return false;
}
/**
* Test.
*/
public static void testDog() {
Dog d = new Dog("Jack");
System.out.println(d.getName() == "Jack");
System.out.println(d.getLegs() == 4);
System.out.println(d.canFly() == false);
}
}