(впервые попрактикуйтесь после изучения OOP концепций. Go немного легко в ответах)
(я просто следую инструкциям из домашней работы "проверь свои навыки"; поэтому я не обсуждаю логика других классов и файлов)
Мне нужно добавить 3 конструктора в один класс, который сам по себе расширен от родительского класса.
Первый конструктор использует те же параметры конструктора из родительского класса .
Второй и третий конструктор продолжают добавлять параметры соответственно.
Я не понимаю синтаксис тела 2-го и 3-го конструкторов.
public class House
extends Building {
// TODO - Put your code here.
private String mOwner;
private boolean mPool;
//This constructor exists in Building class. So, I can use it here with super keyword. Right?
public House(int length, int width, int lotLength, int lotWidth){
super(length, width, lotLength, lotWidth);
}
//Is using "this" keyword okay here? I am just using the constructor existing in this file.
public House(int length, int width, int lotLength, int lotWidth, String Owner){
this(length, width, lotLength, lotWidth);
mOwner = Owner;
}
// Is this right?
public House(int length, int width, int lotLength, int lotWidth, String Owner, boolean pool){
this(length, width, lotLength, lotWidth, Owner);
mPool = pool;
}
}