Add: assignment 2 close #2
This commit is contained in:
46
assignment2/Question1/Sport.java
Normal file
46
assignment2/Question1/Sport.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
|
||||
* Date: 2022/03/04
|
||||
* Description: This is the Sport class.
|
||||
*/
|
||||
|
||||
public class Sport {
|
||||
private int playerNumber;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param playerNumber
|
||||
*/
|
||||
public Sport(int playerNumber) {
|
||||
this.playerNumber = playerNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for playerNumber.
|
||||
*
|
||||
* @return playerNumber
|
||||
*/
|
||||
public int getPlayerNumber() {
|
||||
return playerNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the sport is fun or not. Some sport are fun and some sports are not
|
||||
* fun. By default the sport is not fun.
|
||||
*
|
||||
* @return true if the sport is fun, false if the sport is not fun.
|
||||
*/
|
||||
public boolean isFun() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test.
|
||||
*/
|
||||
public static void testSport() {
|
||||
Sport sport = new Sport(10);
|
||||
System.out.println(sport.getPlayerNumber() == 10);
|
||||
System.out.println(sport.isFun() == false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user