Нужна помощь, дали задание на рефакторинг данного кода, нужно применить наследование. Имеем предметную область автосалон.
public class Car {
public String name;
public String bodyType;
public int price;
public String toString() {
return name + "(" + bodyType + ")" + " - " + price + "$";
}
}
class HeavyCarInitializator extends Car {
public static String[] names = {
"DAF XF 105", "Volvo FH16", "Renault Magnum", "Mercedes Actros", "Scania S500", "ЗИЛ 157", "МАЗ 2021"};
private static final int[] price = {30000, 100000, 65000, 80000, 90000, 15000, 19000};
public static final String[] bodyType = {"Mixer","Truck","Garbage","Crane","Garbage","Crane","Truck"};
public static void init(Car[] HeavyCars) {
for (int i = 0; i < HeavyCars.length; i++) {
HeavyCars[i].name = names[i];
HeavyCars[i].price = price[i];
HeavyCars[i].bodyType = bodyType[i];
}
}
}