Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

[85%) you will be writing six classes which implement a hierarchy of classes. The classes all have to do with motor vehicles I. A MotorVehicle

image text in transcribed

image text in transcribed

[85%) you will be writing six classes which implement a hierarchy of classes. The classes all have to do with motor vehicles I. A MotorVehicle has several attributes: make, model, year, maximum speed, weight, price A car has all the attributes ofa MotorVehicle, plus another attribute: four wheels. A MotorCycle has all the attributes of a MotorVehicle, plus three other attributes: two wheels, two passengers and one of three possible styles ( "Scooter", "Regular" and "Sport") A Compact has all the attributes of a Car, plus two other attributes: can have 4 passengers, 2 doors and a possible sunroof. A HatchBack has all the attributes of a Car, plus two other attributes: can have 5 passengers, 3 doors and a possible sunroof. AMiniVan has all the attributes of a Car, plus two other attributes: can have 7 passengers, 5 doors and a possible trailer-hitch. Here's a test program which uses the above hierarchy: // File Garage.java // Author: Daniel Ling / Purpose: A test harness program, to instantiate and use objects of related types (inheritance hierarchy) public class Garage public static void main (String[] args) f Motorvehicle [ ] vehicles new Motorvehicle [5] ; vehicles [0] = new Motorcycle ("YAMAHA", "YW50FB", vehicles [1] new Compact ("Chevrolet", "Sprite", 1998, 120, 1000, vehicles [2] =new Minivan ("Toyota", "Sienna", 2005, 180, 2200, vehicles [3] new Hatchback ( "Volkswagen", "Gorgon", 1999, 140, 1500, vehicles [4]new MotorCycle ("SUZUKI", "Boulevard C50", for (MotorVehicle motorVehicle : vehicles) 2012, 100, 170, 5395.00, "Scooter" 1800.00, true) 12500.00, true) 3900.00, false) 2005, 180, 210, 5200.00, "Sport"); System.out.println (motorVehicle); 1 // main / class Garage

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students explore these related Databases questions