Add: assignment 2 close #2
This commit is contained in:
33
assignment2/Question1/Tennis.java
Normal file
33
assignment2/Question1/Tennis.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
|
||||
* Date: 2022/03/04
|
||||
* Description: This is the Tennis class which is the subclass of the Sport class.
|
||||
*/
|
||||
|
||||
public class Tennis extends Sport {
|
||||
/**
|
||||
* Constructor. Tennis has 2 player.
|
||||
*/
|
||||
public Tennis() {
|
||||
super(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tennis is fun.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean isFun() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test.
|
||||
*/
|
||||
public static void testTennis() {
|
||||
Tennis t = new Tennis();
|
||||
System.out.println(t.getPlayerNumber() == 2);
|
||||
System.out.println(t.isFun() == true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user