51 lines
964 B
Java
51 lines
964 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 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);
|
|
}
|
|
}
|