44 lines
1003 B
Java
44 lines
1003 B
Java
/*
|
|
* 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 Marathon extends Running {
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param playerNumber
|
|
* the player number
|
|
* @param length
|
|
* the length of the marathon
|
|
*/
|
|
public Marathon(int playerNumber, double length) {
|
|
super(playerNumber, length);
|
|
}
|
|
|
|
/**
|
|
* Constructor. Always set the length to 42.195
|
|
*
|
|
* @param playerNumber
|
|
*/
|
|
public Marathon(int playerNumber) {
|
|
this(playerNumber, 42.195);
|
|
}
|
|
|
|
/**
|
|
* Test.
|
|
*/
|
|
public static void testMarathon() {
|
|
Marathon m1 = new Marathon(1, 39.39);
|
|
System.out.println(m1.getLength() == 39.39);
|
|
System.out.println(m1.getPlayerNumber() == 1);
|
|
System.out.println(m1.isFun() == false);
|
|
|
|
Marathon m2 = new Marathon(2);
|
|
System.out.println(m2.getLength() == 42.195);
|
|
System.out.println(m2.getPlayerNumber() == 2);
|
|
System.out.println(m2.isFun() == false);
|
|
}
|
|
}
|