Lab 6
Start Now

Overview

For this assignment, you will generate a UML class diagram for a class and implement it.

You may choose to implement your class in IntelliJ or using Android Studio.

Assignment

House and BuildingCostEstimator classes

Study the following program. It makes use of a BuildingCostEstimator class. You will need to implement the BuildingCostEstimator class so that the program functions properly.

import java.util.Scanner;

/**
 * Makes use of the BuildingCostEstimator class to estimate the
 * cost of building a house based on the user's desires.
 * 
 * @author Dr. Chris Taylor
 * @version 2016.09.27
 */
public class House {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.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: ");
		int sqFeet = in.nextInt();
		estimator.setSquareFeet(sqFeet);

		System.out.print("Enter the number of full bathrooms: ");
		int numFullBaths = in.nextInt();
		estimator.setNumFullBaths(numFullBaths);

		System.out.print("Enter the number of half bathrooms: ");
		int numHalfBaths = in.nextInt();
		estimator.setNumHalfBaths(numHalfBaths);

		System.out.print("Enter the number of bedrooms: ");
		int numBeds = in.nextInt();
		estimator.setNumBedrooms(numBeds);

		System.out.print("Enter the number of windows: ");
		int numWindows = in.nextInt();
		estimator.setNumWindows(numWindows);

		System.out.print("Enter the number of garage spaces (e.g., 2.5): ");
		estimator.setNumGarages(in.nextDouble());
		
		if(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): ");
			estimator.setNumGarages(in.nextDouble());
		}

		// Display characteristics and cost of the house
		System.out.print("The cost of building this house with ");
		System.out.printf("%d full baths, %d half baths,\n",
				estimator.getNumFullBaths(),
				estimator.getNumHalfBaths());
		System.out.printf("%d bedrooms, %d windows,\n",
				estimator.getNumBedrooms(),
				estimator.getNumWindows());

		System.out.printf("with a %f car garage and taking ",
				estimator.getNumGarages());

		System.out.printf("up %d square feet\n",
				estimator.getSquareFeet());

		System.out.printf("will take $%.2f to build.",
				estimator.costToBuild());
	}
}

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

  • Based cost per square foot of the house: $130
  • Add $15,000 for each full bathroom
  • Add $7,000 for each half bathroom
  • Add $3,000 for each bedroom
  • Add $800 for each window
  • Add $8,000 for each garage stall

Android Option

You may choose to copy the House into an IntelliJ project and then implement the required BuildingCostEstimator class or download this Android project and implement the required BuildingCostEstimator class within Android Studio.

Downloading and installing Android Studio does require additional time, so make sure you are able to commit additional time to this assignment if you chose to go the Android route. You may find one or both of the following links helpful: link 1 and link 2.

Once you have Android Studio installed, extract the HouseEstimator folder from the .zip file. This folder contains the Android project. Start Android Studio, pick Open an existing Android Studio Project, and select the HouseEstimator folder. Once the project loads, click on "Install Build Tools 24.0.1 and sync project" if prompted.

UML Diagram

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

Lab Deliverables

See your professor's instructions for details on submission guidelines and due dates.
Prof. Contino's class: See Blackboard
Prof. Jones' class: See Blackboard
See Dr. Dennis for instructions
Dr. Riley's class: See Blackboard
Dr. Taylor's class: See below
See Prof. Thomas for instructions
If you have any questions, consult your instructor.

Acknowledgement

This laboratory assignment was developed by Dr. Chris Taylor.

Thursday, 29-Sep-2016 11:59:20 CDT