Add: assignment 2 close #2

This commit is contained in:
2022-04-03 17:23:02 +08:00
parent 80ae76b597
commit 5e9fc07694
13 changed files with 448 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
/*
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
* Date: 2022/03/04
* Description: This is the Running class which is the subclass of the Sport class
*/
public class Running extends Sport {
/**
* The length of the running.
*/
private double length;
/**
* Constructor.
*
* @param playerNumber the player number of the running.
* @param length the length of the running
*/
public Running(int playerNumber, double length) {
super(playerNumber);
this.length = length;
}
/**
* Getter for the length of the running.
*/
public double getLength() {
return length;
}
/**
* Running is not fun.
*
* @return false
*/
@Override
public boolean isFun() {
return false;
}
/**
* Test.
*/
public static void testRunning() {
Running r1 = new Running(1, 1.5);
System.out.println(r1.getPlayerNumber() == 1);
System.out.println(r1.getLength() == 1.5);
System.out.println(r1.isFun() == false);
}
}