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

Problem #3: Houses (40 Points) For this problem, you will be creating a derived

ID: 3710838 • Letter: P

Question

Problem #3: Houses (40 Points) For this problem, you will be creating a derived class, base class and an Interface. No Driver is required, but I have attached one to test with. A UML diagram for this problem has been provided to assist you. House Class: Attribute: o Number of Windows Methods: o get and set methods for attribute o toString): returns a String describing the House o constructor that takes in the number of windows in the House Heatable Interface: Heatable should be its own interface which has a: . Method header: heat(): returns how much energy is required to heat object. Ranch: Ranch should be its own class and should inherit from House and implement Heatable. Ranch should have: e Attributes: o is raised-ranch or regular (true if raised, false if regular) . Methods: o get and set methods for attribute o toString): returns a String describing the Ranch o constructor which takes in the Ranch's window count o constructor which takes in the Ranch's window count and raised/regular data o Heatable() returns 23.45 number of windows Grading Breakdown: . 10 Correctly creating your Interface 10-Correctly creating your Base Object 10-Correctly creating your Derived Object 10 Correctly connecting your data using the correct keywords, etc. ?Driver.java

Explanation / Answer

House class:

//creating House class

public class House

{

//attributes

int numOfWindows;

//getter and setter methods

public int getNumOfWindows() {

return numOfWindows;

}

public void setNumOfWindows(int numOfWindows) {

this.numOfWindows = numOfWindows;

}

//toString() method

public String toString()

{

return "House [numOfWindows=" + numOfWindows + "]";

}

//default constructor

public House() {}

//parameterized constructor

public House(int numOfWindows)

{

super();

this.numOfWindows = numOfWindows;

}

}//end of House class

Heatable interface:

//interface Hetable

public interface Hetable

{

//method

public abstract double heat();

}//end of interface Hetable

Ranch class:

//class Ranch

public class Ranch extends House implements Hetable

{

//attributes

boolean isRaised;

//getter and setter methods

public boolean isRaised() {

return isRaised;

}

public void setRaised(boolean isRaised) {

this.isRaised = isRaised;

}

//toString() method

public String toString()

{

return "Ranch [isRaised=" + isRaised + "]";

}

//default constructor

public Ranch() {}

//parameterized constructor-window count

public Ranch(int windowCount)

{

super(windowCount);

}

//parameterized constructor-window count and raised

public Ranch(int numOfWindows, boolean isRaised)

{

super(numOfWindows);

this.isRaised = isRaised;

}

//override and implement abstract method

public double heat()

{

return 23.45*super.numOfWindows;

}

}

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