Lab 09

PLEASE NOTE: All lab exercises are due Monday by 10:00am.
  1. Download Files
  2. Drawing a House
  3. Request Lab Solutions

Download Files

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.

Building Homes With Private Methods

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:

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
width = 4
roofHeight = 4
colour = "red"
numStories = 1
width = 2
roofHeight = 1
colour = "blue"

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.


Request Lab Solutions

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.