Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BASIC JAVA CODE JAVA JAVA complete a programming project that incorporates inheritance The International Building Code (IBC) requires that all buildings and structures must be

BASIC JAVA CODE

JAVA

JAVA

complete a programming project that incorporates inheritance

The International Building Code (IBC) requires that all buildings and structures must be classified by group and occupancy according to the follow specifications: image text in transcribed

A local architecture firm has asked your company to develop a mapping application for all of its projects. Your Software Architecture Team has drafted the following UML Class Diagram with only two occupancy groups (Business and Residential) with which to get started.

image text in transcribed

Using the UML Class Diagram write a prototype for the system with the following specifications: 1. Building class: this is the superclass for all objects in our system. It contains the following

instance members/constructors/methods:

  1. projectName the name of the building project e.g. Smith House.

  2. completeAddress the complete address of the project e.g. 123 Main Street,

    St. Louis, Missouri 63116.

  3. totalSquareFeet the square footage of the building (e.g. 2,500 square feet)

  4. occupancyGroup group code according to Table 1.

  5. subgroup subgroup code according to Table 1.

  6. Constructors there are two constructors. An empty-argument constructor that

    should set all instance fields to or 0.0 as appropriate. The preferred constructor

    should support passing parameters for each instance field.

  7. draw method eventually this will be used to draw the object to the screen. For

    the prototype, it will simply print to the console: Drawing code for

    Type>>. All of the draw methods in the subclasses will do the same.

  8. displayData method will return a formatted String that contains all of the

    information about the object.

2. Business class: this subclass of Building has the following instance members/constructors/methods:

  1. numRentableUnits the number of units in the building that can be rented.

  2. Constructors there are two constructors. An empty-argument constructor that should set all instance fields as appropriate for the data type. The preferred

    constructor should support passing parameters for each instance field.

  3. draw method eventually this will be used to draw the object to the screen. For the prototype, it will simply print to the console: Drawing code for

    Type>>. All of the draw methods in the subclasses will do the same.

  4. displayData method will return a formatted String that contains all of the

    information about the object.

  1. Mall class: this subclass of Business has the following instance members/constructors/methods:

    1. numRentedUnits the number of units in the building that are currently being rented.

    2. medianUnitSize the mall contains rentable units of different size. This instance member represents the median of all of the unit sizes.

    3. numParkingSpaces the total number of parking spaces around the mall.

    4. Constructors there are two constructors. An empty-argument constructor that should set all instance fields as appropriate for the data type. The preferred

      constructor should support passing parameters for each instance field.

    5. draw method eventually this will be used to draw the object to the screen. For the prototype, it will simply print to the console: Drawing code for

      Type>>. All of the draw methods in the subclasses will do the same.

    6. displayData method will return a formatted String that contains all of the

      information about the object.

4. Residential class: this subclass of Building represents a building where people can live

(has bedrooms and bathrooms) and has the following instance members/constructors/methods:

  1. numBedrooms the number of bedrooms in the building.

  2. numBathrooms the number of bathrooms in the building.

  3. laundryRoom whether or not the building has a laundry room.

  1. Constructors there are two constructors. An empty-argument constructor that should set all instance fields as appropriate for the data type. The preferred constructor should support passing parameters for each instance field.

  2. draw method eventually this will be used to draw the object to the screen. For the prototype, it will simply print to the console: Drawing code for >. All of the draw methods in the subclasses will do the same.

  3. displayData method will return a formatted String that contains all of the information about the object.

  1. Apartment class: this subclass of Residential represents a building where more than one family can live and has the following instance members/constructors/methods:

    1. numRentableUnits the number of units that can be rented in the building.

    2. avgUnitSize the average size of the apartments (square footage) in the building.

    3. parkingAvailable a boolean value that indicates if onsite parking is available for

      this building.

    4. Constructors there are two constructors. An empty-argument constructor that

      should set all instance fields as appropriate for the data type. The preferred

      constructor should support passing parameters for each instance field.

    5. draw method eventually this will be used to draw the object to the screen. For the prototype, it will simply print to the console: Drawing code for

      Type>>. All of the draw methods in the subclasses will do the same.

    6. displayData method will return a formatted String that contains all of the

      information about the object.

  1. SingleFamilyHome class: this subclass of Residential represents a building where a one family lives (has a limit on the number of people who can live there). This class has the following instance members/constructors/methods:

    1. garage a boolean value that indicates whether or not the house has a garage.

    2. Constructors there are two constructors. An empty-argument constructor that should set all instance fields as appropriate for the data type. The preferred

      constructor should support passing parameters for each instance field.

    3. draw method eventually this will be used to draw the object to the screen. For the prototype, it will simply print to the console: Drawing code for

      Type>>. All of the draw methods in the subclasses will do the same.

    4. displayData method will return a formatted String that contains all of the

      information about the object.

  1. Application class: After you have completed your inheritance hierarchy, write an Application class (not shown in the UML Class Diagram) to test every object. In your test, create an instance of every object and then write code to test every constructor/method/getter/setter/toString for the object. Start with the most generic object and move to the more specific object.

Notes:

  1. Notice that every class has constructor that accepts the protected fields in Building (for consistency).

  2. There is an empty-argument and a preferred constructor for each object. (Use the tools built into Eclipse to generate these)

  3. Every object should have getters/setters for every instance field. (Use the tools built into Eclipse to generate these)

  1. Every object should have a toString method (Use the tools built into Eclipse to generate these)

  2. Ensure you follow the StyleGuide and fully comment/Javadoc the project.

  3. Some objects have a displayData method. When that method is called it should return a

    formatted string with all of the instance fields that the object can see. The format needs to be consistent from object to object, but you can choose the format. See below for examples:

image text in transcribed

OCCUPANCY GROUP Assembly Business Educational Factory/Industrial High Hazard Institutional Mercantile Residential Storage SUBGROUPS USES INCLUDE Groups A-1, A-2, A-3, A-4, & A-5 Gatherings, civic/religious/social/recreational Group B Office/Professional or Service Transactions Group E K-12 Schools (some Daycare) Groups F-1 & F-2 Manufacturing/Fabrication/Packaging Groups H-1, H-2, H-3, H-4, & H-5 Hazardous Materials Groups 1-1, 1-2, 1-3, & 1-4 Assisted Living/Hospitals/Prisons Group M Display & Sale of Merchandise Groups R-1, R-2, R-3, & R-4 Housing/Apartments/Hotels Groups S-1 & S-2 Non or Low-Hazardous Storage (including parking garages) Group U Accessory Structures Utility & Miscellaneous Building #projectName: String #completeAddress: String #totalSquare Feet: double #occupancyGroup: String #subgroup: String +Building() +Building (String projectName, String complete Address, double totalSquareFeet, String occupancyGroup, String subgroup) +draw(): void +displayData(): String Residential Business #numRentableUnits: int +Business() +Business(String projectName, String complete Address, double totalSquareFeet, String occupancyGroup, String subgroup) #num Bedrooms: int #num Bathrooms: int #laundry Room: boolean +Residentiall) +Residential(String projectName, String complete Address, double totalSquareFeet, String occupancyGroup, String subgroup) Mall Apartment SingleFamily Home -numRented Units -medianUnitSize: double -numParking Spaces: int +Mall() +Mall(String projectName, String complete Address, double totalSquare Feet, String occupancyGroup, String subgroup) +draw(); void +displayData(): String -numRentableUnits: int -avgUnitSize: double - parking Available: boolean +Apartment() +Apartment(String projectName, String completeAddress, double totalSquareFeet, String occupancyGroup, String subgroup) +draw(): void +displayData(): String -garage: boolean +Single Family Homel) +Single FamilyHome(String projectName, String complete Address, double totalSquare Feet, String occupancyGroup, String subgroup) +draw(): void +displayData(): String Building SingleFamily Home Project Name: Gaines House Project Name: Gaines House Address: 123 Main Street | Louisville, Address: 123 Main Street | Louisville, Kentucky 40201 Kentucky 40201 Square Feet: 2540 Square Feet: 2540 Occupancy Group :Residential Occupancy Group :Residential Occupancy Subgroup: R1 Occupancy Subgroup: R1 Number of Bedrooms: 4 Number of Bathrooms: 3 Laundry Room: Y Garage: Y OCCUPANCY GROUP Assembly Business Educational Factory/Industrial High Hazard Institutional Mercantile Residential Storage SUBGROUPS USES INCLUDE Groups A-1, A-2, A-3, A-4, & A-5 Gatherings, civic/religious/social/recreational Group B Office/Professional or Service Transactions Group E K-12 Schools (some Daycare) Groups F-1 & F-2 Manufacturing/Fabrication/Packaging Groups H-1, H-2, H-3, H-4, & H-5 Hazardous Materials Groups 1-1, 1-2, 1-3, & 1-4 Assisted Living/Hospitals/Prisons Group M Display & Sale of Merchandise Groups R-1, R-2, R-3, & R-4 Housing/Apartments/Hotels Groups S-1 & S-2 Non or Low-Hazardous Storage (including parking garages) Group U Accessory Structures Utility & Miscellaneous Building #projectName: String #completeAddress: String #totalSquare Feet: double #occupancyGroup: String #subgroup: String +Building() +Building (String projectName, String complete Address, double totalSquareFeet, String occupancyGroup, String subgroup) +draw(): void +displayData(): String Residential Business #numRentableUnits: int +Business() +Business(String projectName, String complete Address, double totalSquareFeet, String occupancyGroup, String subgroup) #num Bedrooms: int #num Bathrooms: int #laundry Room: boolean +Residentiall) +Residential(String projectName, String complete Address, double totalSquareFeet, String occupancyGroup, String subgroup) Mall Apartment SingleFamily Home -numRented Units -medianUnitSize: double -numParking Spaces: int +Mall() +Mall(String projectName, String complete Address, double totalSquare Feet, String occupancyGroup, String subgroup) +draw(); void +displayData(): String -numRentableUnits: int -avgUnitSize: double - parking Available: boolean +Apartment() +Apartment(String projectName, String completeAddress, double totalSquareFeet, String occupancyGroup, String subgroup) +draw(): void +displayData(): String -garage: boolean +Single Family Homel) +Single FamilyHome(String projectName, String complete Address, double totalSquare Feet, String occupancyGroup, String subgroup) +draw(): void +displayData(): String Building SingleFamily Home Project Name: Gaines House Project Name: Gaines House Address: 123 Main Street | Louisville, Address: 123 Main Street | Louisville, Kentucky 40201 Kentucky 40201 Square Feet: 2540 Square Feet: 2540 Occupancy Group :Residential Occupancy Group :Residential Occupancy Subgroup: R1 Occupancy Subgroup: R1 Number of Bedrooms: 4 Number of Bathrooms: 3 Laundry Room: Y Garage: Y

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

Students also viewed these Databases questions

Question

What is group replacement? Explain with an example. (2-3 lines)

Answered: 1 week ago

Question

Why could the Robert Bosch approach make sense to the company?

Answered: 1 week ago