Question: I need help with this public class Building { OneBuilding data; Building older; Building same; Building younger; public Building(OneBuilding data){ this.data = data; this.older =
I need help with this
public class Building {
OneBuilding data; Building older; Building same; Building younger; public Building(OneBuilding data){ this.data = data; this.older = null; this.same = null; this.younger = null; } public String toString(){ String result = this.data.toString() + " "; if (this.older != null){ result += "older than " + this.data.toString() + " : "; result += this.older.toString(); } if (this.same != null){ result += "same age as " + this.data.toString() + " : "; result += this.same.toString(); } if (this.younger != null){ result += "younger than " + this.data.toString() + " : "; result += this.younger.toString(); } return result; } public Building addBuilding (OneBuilding b){ // ADD YOUR CODE HERE return this; // DON'T FORGET TO MODIFY THE RETURN IF NEEDS BE public Building addBuildings (Building b){ // ADD YOUR CODE HERE return this; // DON'T FORGET TO MODIFY THE RETURN IF NEEDS BE } public Building removeBuilding (OneBuilding b){ // ADD YOUR CODE HERE return this; // DON'T FORGET TO MODIFY THE RETURN IF NEEDS BE } public int oldest(){ // ADD YOUR CODE HERE return 0; // DON'T FORGET TO MODIFY THE RETURN IF NEEDS BE } public int highest(){ // ADD YOUR CODE HERE return 0; // DON'T FORGET TO MODIFY THE RETURN IF NEEDS BE } public OneBuilding highestFromYear (int year){ // ADD YOUR CODE HERE return new OneBuilding("",0,0,0,0); // DON'T FORGET TO MODIFY THE RETURN IF NEEDS BE } public int numberFromYears (int yearMin, int yearMax){ // ADD YOUR CODE HERE return 0; // DON'T FORGET TO MODIFY THE RETURN IF NEEDS BE } public int[] costPlanning (int nbYears){ // ADD YOUR CODE HERE return new int[0]; // DON'T FORGET TO MODIFY THE RETURN IF NEEDS BE } }
//package assignment3;
public class OneBuilding {
final String name; final int yearOfConstruction; final int height; final int yearForRepair; final int costForRepair; public OneBuilding(String name, int yearOfConstruction, int height, int yearForRepair, int costForRepair){ this.name = name; this.yearOfConstruction = yearOfConstruction; this.height = height; this.yearForRepair = yearForRepair; this.costForRepair = costForRepair; } public String toString(){ String result = this.name + "(" + this.yearOfConstruction + " , " + this.height + ")"; return result; } public boolean equals(OneBuilding b){ boolean temp = this.name.equals(b.name); temp = temp && this.yearForRepair == b.yearForRepair; temp = temp && this.yearOfConstruction == b.yearOfConstruction; temp = temp && this.height == b.height; temp = temp && this.costForRepair == b.costForRepair; return temp; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
