Download the L09.zip file and extract
the files to your cs125 folder in your home directory.
You will use these files to complete this week's lab exercises.
You must fill in the code missing in the provided Home.java
class. The class must use private methods to draw a house on a Board with a given set of dimensions.
The only public method is the constructor which takes the following in this order:
int indicating how many stories are in the main part of the
house. Each story is 3 units tall.
int indicating how many units wide the house is. This is
how long a line from the left wall to the right wall would be.
int indicating how many units tall the roof is. This is
how long a line from the top to the bottom of the roof would be.
String indicating what colour all the squares completely
contained within the main part of the house should be.
The following is a couple of houses and how they were created. The second house represents the smallest possible house that you can create which does not violate the preconditions of the constructor.
numStories = 3 |
numStories = 1 |
![]() |
![]() |
You must complete the constructor. As well, you must write all the helper methods that are indicated with comments in the bottom of the class. Each of the helper methods is at most 5 or 6 lines, and performs one small, useful task required to implement the drawing.
You must actually use those helpers. You may write additional helpers if needed.
Be sure to test your code!
Submit the completed code for Home.java below. Note that
submitting solutions to a similar question
from a previous term will not be accepted. You are expected to author
your own solution to all of your lab work and this is definitely no
exception.
If you request solutions for this lab you will be sent an email that contains your answers as well as the expected answers. The email will be sent out to all interested students once the deadline for completing the exercises has passed for all students.