weight = 16


For this assignment, you will generate a UML class diagram for a class and implement it. In addition, you will learn how to use GitHub classroom to start a new project and submit your solution using git version control.

Pre-Lab (DUE BEFORE LAB - see due date in Canvas)

As part of the pre-lab activity you will see how to use GitHub Classroom to start your lab assignment and submit it when you are finished.

  • How to start a new project from your GitHub repository
  • How to commit changes to your local repo
  • How to push changes from your local repo to GitHub
  • How to add a file to your project that is not under version control
  • How to add a file to your project that is under version control
  • How to update your local repo with changes from the GitHub repo (e.g., after your assignment has been graded)
  • How to see the differences between the most recent verion in your repo and the current files in your project

The project is cloned from the GitHub repo to your local machine at the three minute mark in the video. You will likely need to authorize IntelliJ to access your GitHub account. Hopefully the process is simple enough, but you can see screenshots of what to do in Figures 13-16 of this page.

What Must Be Done by the Pre-lab Due Date?


House and BuildingCostEstimator classes

The House class in the project defines a program that makes use of a BuildingCostEstimator class. You will need to implement the BuildingCostEstimator class so that the program functions properly.

 * Course: CS-1011-011
 * Fall 2021
 * Lab 6 - Simple Class
 * Name: Sean Jones
 * Created: 09/27/16
 * Modified: 10/12/21
package username;

import java.util.Scanner;

 * Makes use of the BuildingCostEstimator class to estimate the
 * cost of building two houses based on the user's desires.
 * @author Dr. Chris Taylor and Prof. Sean Jones
 * @version 2021.10.12
public class House {
    private static final int SIMILAR_THRESHOLD = 8;
    private static final int DIFFERENT_THRESHOLD = 25;
    private static final int TO_PERCENT = 100;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        BuildingCostEstimator estimator1 = getBuildingCostEstimator(in);
        BuildingCostEstimator estimator2 = getBuildingCostEstimator(in);
        double cost1 = estimator1.costToBuild();
        double cost2 = estimator2.costToBuild();
        double percentDifference = TO_PERCENT * 2 * Math.abs(cost1-cost2)/(cost1+cost2);
        String costDeltaDescription = "\nYou are comparing two houses that ";
        if(percentDifference < SIMILAR_THRESHOLD) {
            costDeltaDescription += "cost a similar amount.";
        } else if(percentDifference > DIFFERENT_THRESHOLD) {
            costDeltaDescription += "cost wildly different amounts.";
        } else {
            costDeltaDescription += "have significant cost differences.";
        if(estimator1.costToBuild()>=estimator2.costToBuild()) {
            System.out.println("\nThe first house is more expensive...\n");
            System.out.println("\nThe second house is less expensive...\n");
        } else {
            System.out.println("\nThe second house is more expensive...\n");
            System.out.println("\nThe first house is less expensive...\n");

     * Display characteristics and cost of the house
     * @param estimator The building cost estimator object to display
    private static void displayDetails(BuildingCostEstimator estimator) {
        System.out.print("The cost of building this house with ");
        System.out.format("%d full baths, %d half baths,\n",
        System.out.format("%d bedrooms, %d windows,\n",
        System.out.format("with a %.1f car garage and taking ",
        System.out.format("up %d square feet\n",
        System.out.format("will take $%,.2f to build.\n",

     * Gathers information about the user's desires and creates and returns a
     * building cost estimator object.
     * @param in The scanner used to obtain user input
     * @return a building cost estimator that is consistent with the user's responses
    private static BuildingCostEstimator getBuildingCostEstimator(Scanner in) {
        BuildingCostEstimator estimator = new BuildingCostEstimator();
        System.out.println("This program will help you estimate the "
                + "cost of building a house.");
        System.out.println("For your desired house:");
        System.out.print("Enter the total number of square feet: ");
        String line = in.nextLine();
        int sqFeet = Integer.parseInt(line);
        System.out.print("Enter the number of full bathrooms: ");
        int numFullBaths = Integer.parseInt(in.nextLine());
        System.out.print("Enter the number of half bathrooms: ");
        line = in.nextLine();
        System.out.print("Enter the number of bedrooms: ");
        int numBeds = Integer.parseInt(in.nextLine());
        System.out.print("Enter the number of windows: ");
        System.out.print("Enter the number of garage spaces (e.g., 2.5): ");
        line = in.nextLine();
        while(estimator.getNumGarages()<2.0) {
            System.out.println("We are in Wisconsin.");
            System.out.println("Perhaps you should reconsider the number of garage stalls.");
            System.out.print("Enter the number of garage spaces (e.g., 2.5): ");
        return estimator;

The cost of the home should be based on the following calculation:

UML Diagram

You must generate a UML class diagram for the BuildingCostEstimator class.


This laboratory assignment was developed by Dr. Chris Taylor.

See your professor's instructions for details on submission guidelines and due dates.