Add: assignment 2 close #2
This commit is contained in:
37
assignment2/Question2/SportsCourt.java
Normal file
37
assignment2/Question2/SportsCourt.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user