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,37 @@
/*
* 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);
}
}