Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write class Taxi with the following requirements. It is a subclass of the Vehicle class. It has a private variable named colour to store

Write class Taxi with the following requirements.

 

  • It is a subclass of the Vehicle class.
  • It has a private variable named colour to store the colour of the taxi, i.e. "Red", Green" or "Blue".
  • It has another private variable named ini_fare to store the initial fare of the taxi.
  • It has a constructor which does the follows:
    • Receives two variables: regno and colour.
    • Invokes parent's constructor (a taxi always has 4 wheels and 5 seats).
    • Base on the colour, set the ini_fare according to the following table.
imageimage

There is only a getter method for regno ( getRegno() ) but no setter method for it. Discuss why there is no such setter method.

You are given the Vehicle class below. class Vehicle { private String regno; private int numOfWheels; private int seats; public Vehicle(String regno, int numOfWheels, int seats) { this.regno = regno; this.numOfWheels == numOfWheels; this.seats = seats; } public String getRegno() { } } return regno; Time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Here is the implementation of the Taxi class that meets the given requirements java public class Taxi extends Vehicle private String colour private do... 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

Starting Out With Python Global Edition

Authors: Tony Gaddis

4th Edition

1292225750, 9781292225753

More Books

Students also viewed these Programming questions

Question

What is a Boolean function?

Answered: 1 week ago