This commit is contained in:
2022-03-19 17:47:52 +08:00
parent 6bf672bd5b
commit 1c8f95c4b3
35 changed files with 1597 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
/*
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
* Date: 2022/03/19
* Description: Student class
*/
public class Student {
/**
* Student's name
*/
private String name;
/**
* Student's pet
*/
private Cat pet;
/**
* Constructor
*/
public Student(String name, Cat pet) {
this.name = name;
this.pet = pet;
}
/**
* Getter for name
*
* @return String
*/
public String getName() {
return name;
}
/**
* Getter for pet
*
* @return Cat
*/
public Cat getPet() {
return pet;
}
/**
* Test
*/
public static void testStudent() {
Cat cat = new Cat("Tom", 1.0);
Student student = new Student("Walter", cat);
System.out.println(student.getName() == "Walter");
System.out.println(student.getPet() == cat);
System.out.println(student.getPet().getName() == "Tom");
System.out.println(student.getPet().getWeight() == 1.0);
}
}