Close: #1 Lab 7

This commit is contained in:
2022-04-03 15:14:47 +08:00
parent 85b623f65f
commit 80ae76b597
53 changed files with 2677 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
/*
* 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);
}
}