Question

You are given a specification for some Java classes as follows.   A building has a number...

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 isn’t Florida-like … it’s 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, it’s 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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*; Try public class ArrayListDemo f public static void main(String args]) // create an array list ArrayList

Add a comment
Know the answer?
Add Answer to:
You are given a specification for some Java classes as follows.   A building has a number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Build a java program that has Student class, use arrays of objects {name, age, gpa} to...

    Build a java program that has Student class, use arrays of objects {name, age, gpa} to saves 3 students records. Use printable interface with abstract print method. Student class inherits from an abstract Person class that has name, age as attributes. It also has the following 2 methods: abstract setAge and concrete setGPA. Below is the hierarchy and a sample run (using netbeans): Hierarchy: Printable Interface print(Object ( ) ): object ] Abstract Person Class Name: String Age: int Abstract...

  • Templates Apartment.java package hwk7; public class Apartment {    int numOfApartments; // the number of apartments...

    Templates Apartment.java package hwk7; public class Apartment {    int numOfApartments; // the number of apartments of this type    Room[] rooms; // rooms in this type of apartment       Apartment(int numOfApartments, Room[] rooms) {        this.numOfApartments = numOfApartments;        this.rooms = rooms;    }       // Return the window orders for one apartment of this type as TotalOrder object    TotalOrder orderForOneUnit() {        // TODO    }       // Return the window...

  • Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman...

    Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...

  • Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance...

    Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance variables x and y that represented for the coordinates for a point. Provide constructor for initialising two instance variables. Provide set and get methods for each instance variable, Provide toString method to return formatted string for a point coordinates. 2. Create class Circle, its inheritance from Point. Provide a integer private radius instance variable. Provide constructor to initialise the center coordinates and radius for...

  • IN JAVA Design and code a class hierarchy that demonstrates your understanding of inheritance and polymorphism....

    IN JAVA Design and code a class hierarchy that demonstrates your understanding of inheritance and polymorphism. Your hierarchy should contain at least 5 classes and one driver program that instantiates each type of object and runs multiple methods on those objects. Inheritance and Polymorphism must be apparent in the project. Please keep in mind that polymorphism was in chapter 37, so you will need to have read both chapters to understand what goes into this project. Bonus if you add...

  • /*hello everyone. my question is mostly related to the garagetest part of this assignment that i've...

    /*hello everyone. my question is mostly related to the garagetest part of this assignment that i've been working on. i am not sure how to read the file's contents AND put them into variables/an array. should it be in an arraylist? or maybe a regular array? or no arrays at all? i am also not sure how to call the factory method from garagec. i'm thinking something along the lines of [Garage garage = new GarageC.getInstance("GarageC", numFloors, areaofEachFloor);] but i...

  • JAVA :The following are descriptions of classes that you will create. Think of these as service...

    JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...

  • ONLY NEED THE DRIVER CLASS PLEASE!!! Domain & Comparator Classes: 0.) Design a hierarchy of classes,...

    ONLY NEED THE DRIVER CLASS PLEASE!!! Domain & Comparator Classes: 0.) Design a hierarchy of classes, where the Media superclass has the artistName and the mediaName as the common attributes. Create a subclass called CDMedia that has the additional arrayList of String objects containing the songs per album. Create another subclass called DVDMedia that has the additional year the movie came out, and an arrayList of co-stars for the movie. 1.) The superclass Media will implement Comparable, and will define...

  • (The interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal a...

    (The interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make implement the Edible interface. howToEat() and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML diagram for the classes and the interface 2. Use Arraylist class to create an...

  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

    In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT