Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a java class Construction that has the following properties: Builder’s name Year

ID: 3844810 • Letter: A

Question

a java class Construction that has the following properties:

Builder’s name

Year it was built

Area of the construction in square feet

-Provide a Design default constructor that sets Builder’s name to unknown, Year built to 0 and Area to -1

-provide a constructor that accepts specific values for each of the private members

- Provide Accessors for each of the members

-provide mutators for each of the private member

-a Method display that displays all attributes of an object

-Provide a method isEqual that accepts an object Construction and returns true if the object is equal to current object and false otherwise

Explanation / Answer

Here is your code below: -

Construction.java


public class Construction {
   private String builderName;
   private int buildYear;
   private int areaOfConstruction;
   public Construction(String builderName, int buildYear, int areaOfConstruction) {
       this.builderName = builderName;
       this.buildYear = buildYear;
       this.areaOfConstruction = areaOfConstruction;
   }
  
   public Construction() {
       this.builderName = "unknown";
       this.buildYear = 0;
       this.areaOfConstruction = -1;
   }

   public String getBuilderName() {
       return builderName;
   }

   public void setBuilderName(String builderName) {
       this.builderName = builderName;
   }

   public int getBuildYear() {
       return buildYear;
   }

   public void setBuildYear(int buildYear) {
       this.buildYear = buildYear;
   }

   public int getAreaOfConstruction() {
       return areaOfConstruction;
   }

   public void setAreaOfConstruction(int areaOfConstruction) {
       this.areaOfConstruction = areaOfConstruction;
   }
  
   public void display() {
       System.out.println("BuilderName: "+this.builderName);
       System.out.println("Year it was build: "+this.buildYear);
       System.out.println("Area of construction: "+this.areaOfConstruction);
   }
  
   public boolean isEqual(Construction obj) {
       if(this.equals(obj)) {
           return true;
       } else {
           return false;
       }
   }

   @Override
   public int hashCode() {
       final int prime = 31;
       int result = 1;
       result = prime * result + areaOfConstruction;
       result = prime * result + buildYear;
       result = prime * result + ((builderName == null) ? 0 : builderName.hashCode());
       return result;
   }

   @Override
   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (obj == null)
           return false;
       if (getClass() != obj.getClass())
           return false;
       Construction other = (Construction) obj;
       if (areaOfConstruction != other.areaOfConstruction)
           return false;
       if (buildYear != other.buildYear)
           return false;
       if (builderName == null) {
           if (other.builderName != null)
               return false;
       } else if (!builderName.equals(other.builderName))
           return false;
       return true;
   }
  
  
}

ConstructionTester.java


public class ConstructionTester {
   public static void main(String[] args) {
       Construction c = new Construction();
       c.setBuilderName("Akash");
       c.setBuildYear(2016);
       c.setAreaOfConstruction(26);
       Construction c1 = new Construction("Ravish", 2017, 299);
       c.display();
       c1.display();
       System.out.println("Is c and c1 equal: "+c.isEqual(c1));
   }
}

Sample Run: -

BuilderName: Akash
Year it was build: 2016
Area of construction: 26
BuilderName: Ravish
Year it was build: 2017
Area of construction: 299
Is c and c1 equal: false

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote