OverviewFor this assignment, you will generate a UML class diagram for a class and implement it. AssignmentHouse and HouseEstimator classesStudy the following program. It makes use of a HouseEstimator class. You will need to implement the HouseEstimator class so that the program functions properly.
import java.util.Scanner;
/**
* @author Dr. Chris Taylor
* 10-12-2009
*
* Makes use of the HomeEstimator class to estimate the
* cost of building a house based on the user's desires.
*/
public class House {
public static void main(String[] args) {
// Connect scanner object to keyboard for input
Scanner in = new Scanner(System.in);
// Create a new HouseEstimator object
HouseEstimator estimator = new HouseEstimator();
// Get desired house characteristics from the user and populate
// the HouseEstimator object.
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: ");
double sqFeet = in.nextDouble();
estimator.setSquareFeet(sqFeet);
System.out.print("Enter the number of bathrooms: ");
double numBaths = in.nextDouble();
estimator.setNumBathrooms(numBaths);
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 fireplaces: ");
estimator.setNumFireplaces(in.nextInt());
// Display characteristics and cost of the house
System.out.print("The cost of building this house with ");
System.out.printf("%.1f bathrooms, %d bedrooms,\n",
estimator.getNumBathrooms(),
estimator.getNumBedrooms());
System.out.printf("%d windows, and %d fireplaces and taking ",
estimator.getNumWindows(),
estimator.getNumFireplaces());
System.out.printf("up %f 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:
For the minimum requirements, a half-bath may be given a value of $5,000. As an extra challenge, you can opt to make a half-bath worth $7,000. You may assume that there is no more than one half-bath per home. UML Diagram (Due at the beginning of week 6 lab)You must generate a UML class diagram that completely describes the HouseEstimator class. You must bring a hardcopy (you may generate it with a pencil and paper) to lab with you. Demonstration (Due prior to the end of week 6 lab)You should begin be creating method stubs for all of the required methods. Method stubs are blank (or nearly blank) methods that allow the program to compile even though the program likely produces incorrect results. You must demonstrate your "working" program, that is, it compiles and runs but doesn't produce the correct results, before the end of lab. Submission (due at 11pm the day of week 6 lab)Each student must submit their program with complete functionality. The program must contain comments at the beginning of the file that include: Course name, Quarter, Assignment name, Author's name, and date (see here). Student's must use the electronic submission form to submit their code. Enter your MSOE username for the username, select "Lab 5" for the assignment, select your HouseEstimator.java implementation for the report file name and leave the support file name blank. AcknowledgmentThis laboratory assignment was developed by Dr. Chris Taylor. |