Answered step by step
Verified Expert Solution
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
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 Constructors : +Vehicle (make: String, model: int, year: int, mileage: int, plateNumber: String, numSeats: int) +Vehicle (make: String, model: int, year: int, numSeats: int) default values: mileage "unknown" 0; plateNumber: +getMake(): String +getModelo: int +getYear(): int +getMileage(): int +getPlateNumber(): String +getNumSeats: int +setMileage(int mileage): void setMileage: new mileage cannot be less than previous mileage +setPlateNumber(String plateNumber): void +toString: String toString0: Prints make, model and mileage Taxi (inherits Vehicle class) Class All fields of Vehicle class are inherited and have Instance Variables these additional fields. taxild; fare Total; numFares; String double int Constructor: +Taxi (make: String, model: int, year: int, mileage: int, plateNumber: String, numSeats: int, taxild: String) default values: fare Total = 0.0, numFares: 0 getIDO: gives taxi ID +getIDO): String +setID(String newID): void +getFare Total(): double +addFare(double Fare): void +getNumFares: int +getAverageFare (: double getFare Total: gives total fare addFare(): to add new fare to existing fare getNumFares: to give total number of fares get rageFar gets the average of fare +resetFare Info(): void +toString(: String (Overridden method) resetFareInfo(): resets Fare, NumFares to zero toString(: adds Taxild to toString() method of berent
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started