38 lines
646 B
Java
38 lines
646 B
Java
/*
|
|
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
|
|
* Date: 2022/03/04
|
|
* Description: This is the class of SportsCourt.
|
|
*/
|
|
|
|
public class SportsCourt {
|
|
private Sport sport;
|
|
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param sport
|
|
*/
|
|
public SportsCourt(Sport sport) {
|
|
this.sport = sport;
|
|
}
|
|
|
|
/**
|
|
* Getter of sport.
|
|
*
|
|
* @return sport
|
|
*/
|
|
public Sport playSport() {
|
|
return sport;
|
|
}
|
|
|
|
/**
|
|
* Test.
|
|
*/
|
|
public static void testSportsCourt() {
|
|
HalfMarathon hm1 = new HalfMarathon();
|
|
SportsCourt sc1 = new SportsCourt(hm1);
|
|
HalfMarathon hm2 = (HalfMarathon) sc1.playSport();
|
|
System.out.println(sc1.playSport() == hm2);
|
|
}
|
|
}
|