Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are given a specification for some Java classes as follows. A building has a number of floors, and a number of windows. A house

You are given a specification for some Java classes as follows.

A building has a number of floors, and a number of windows.

A house is a building.

A garage is a building. (This isnt Florida-like its a detached garage.)

A room has a length, width, a floor covering, and a number of closets.

You can never create an instance of a building, but every object that is a building must have a method that calculates the floor space, i.e., the Building class is abstract, and has an abstract method.

A house has a number of bathrooms, and an array of Rooms.

A house has a method that returns the average size of the Rooms.

A Garage can hold some number of cars, and it may have a cement floor or a gravel floor. A garage has a length and a width.

1. Describe or Draw the inheritance hierarchy. What inherits from what. (just class names it's small. Include the Object class in your hierarchy).

2. Implement the specification in Java classes.

You must use the following mechanisms correctly:

Inheritance is a

Composition has a

Constructor methods

Accessor / mutator methods = getters, setters

Arrays of objects you can use ArrayList if you know how

Passing arrays of objects to methods or an ArrayList

Abstract classes and methods

Access modifiers public, private (you might find a reason to use protected, its not all that common)

toString() methods in each class

the super keyword

method overriding

method overloading

This program also requires you to demonstrate the OO concepts of: encapsulation

polymorphism

Include a test class that has a main method. This test program will make instances of your classes and output the text representation of the objects using the toString() methods. There should be enough comments in the output so that it is easy to see which classes are being tested.

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

Step: 3

blur-text-image

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions