Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program for a vehicle class (super/parent class) and Taxi class (sub/child class) as per the UML diagram given below. Please use the

image text in transcribedimage text in transcribed

Write a Java program for a vehicle class (super/parent class) and Taxi class (sub/child class) as per the UML diagram given below. Please use the principles of inheritance while declaring classes. Class Instance Variables Vehicle make; String model; int year: int mileage; int plateNumber; String numSeats: int +Vehicle (make: String, model: int, year: int, Constructors: mileage: int, plate Number: String, numSeats: int) +Vehicle (make: String, model: int, year: int. default values: mileage numScats: int) "unknown 0: plateNumber: +getMake(): String + getModel(): int +getYear(: int +getMileage(): int +getPlateNumber(): String +getNumSeats(): int tsetMileage(int mileage): void tsetPlateNumber(String plateNumber): void +toString(): String setMileage: new mileage cannot be less than previous mileage toString(): Prints make, model and mileage Taxi (inherits Vehicle class) Class All ficlds of Vehicle class arc inherited and have Instance Variables these additional fields. taxild: String fare Total; double numFares; int +Taxi (make: String, model: int year: int, mileage: Constructor: int, plateNumber: String, numScats: int, taxild: String) default values: fare Total=0.0; numFares: 0 +getIDO: String getIDO: gives taxi ID +setID(String newID): void +getFare Total(): double getFare Total: gives total fare +addFare(double Fare): void addFare(): to add new fare to existing fare +getNumFares: int getNumFares: to give total number of fares +getAverageFare(): double getAverageFaro: gets the average of fare +resetFarc Info(: void resetFare Info(): resets Fare, NumFares to zero +toString): String (Overridden method) toString(: adds Taxild to toString() method of parent class Specifications Declare a vehicle class with the instanco variables defined above. (Marks 2) Declare all the methods mentioned above inside Vehicle class. (Marks 4) Declare an inherited Taxi class with the instance variables defined above. (Marks 2) Declare all the methods mentioned above inside Taxi class. (Marks 3) Create another class with main method. Create a Taxi object inside main class. The taxiID should be same as your student Id. Show all the instance variable values of Taxi using the get methods. Add two fares and show average fare and number of fares. (Marks 4)

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions