โจทย์ฝึกหัด อันนี้ไม่ต้องส่ง แต่ต้องทำให้ถูกนะ
A a class – Human - already has the following code:
public class Human{
private int life;
private Human[] relatives;
}
1. Write methods for getting and setting
a human’s life respectively.
2. Write a constructor for the class
Human. The constructor receives 2 arguments, and set the human’s two variables
respectively.
3. 3. write a class Test. This class has a main
method that creates a Human with the life being 2 and the relatives being null.
Then the main method sets its life to 5.