Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Quaestion: Interfaces and Parking Garage Class -------------------------------------------------------------------------------------------- interface Domestic { } interface Import { } interface Japanese extends Import { } interface German extends

JAVA Quaestion: Interfaces and Parking Garage Class

--------------------------------------------------------------------------------------------

interface Domestic { } interface Import { } interface Japanese extends Import { } interface German extends Import { } interface Detroit extends Domestic { } interface SpringHill extends Domestic { } interface Vehicle { } interface Automobile extends Vehicle { } interface LargeAutomobile extends Vehicle { } interface Sedan extends Automobile { } interface Van extends LargeAutomobile { } interface Truck extends LargeAutomobile { } interface Compact extends Automobile { } interface SportsUtilityVehicle extends Truck, Van { } class SaturnSL1 implements SpringHill, Sedan { } class HondaCivic implements Japanese, Compact { } class MercedesC230 implements German, Sedan { } class ChevyS10 implements Detroit, Truck { } class SubaruOutback implements Japanese, SportsUtilityVehicle { }

Add the following declaration to interface Vehicle: int getWeightInPounds( );

Then add the minumum amount of additional code to make all the classes that implement Vehicle compile again. Assume that a small car weighs 1,000 pounds, and a large pickup truck weighs 2,500 pounds. Try to write as little redundant code as possible. You may introduce new classes if this would help meet this goal. Write a class ParkingGarage which simulates a garage for parking Vehicles. The garage should have have enough capacity to park 20 Vehicles or 25,000 pounds. It should refuse to park any Vehicle that would push the garage over either of these limits. Note that ParkingGarage should be a well-behaved class; in particular, it should be possible to create multiple independent ParkingGarages in one program. ParkingGarage should have a main routine which demonstrates its capabilities. main( ) need not accept any user input.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions