Computer Science There are clearly some similarities in the implementations of Taxi and Shuttle that suggest use of inheritance to represent them. Introducing inheritance is the primary task of this assessment. -The Ezcab class, The Ezcab class maintains separate lists of taxis and shuttles and destinations with destination fares (you can hardcode destination fares). It has a lookup method that searches for a taxi/shuttle with a given ID. -The Taxi and Shuttle classes share some common attributes – location and destination. They also have some common methods – getLocation, getDestination, getStatus and setDestination. -Vehicle is the superclass of both Taxi and Shuttle. This class involves placing the common fields and methods into Vehicle and removing them from Taxi and Shuttle. -Modify Taxi and Shuttle class to indicate that it is a subclass of Vehicle. You can keep the id field in Vehicle class and getId,SetId methods. -Arrange for Taxi's constructor to call the constructor of Vehicle so that a value for id is passed. -In the Shuttle class, Make Shuttle a subclass of Vehicle. You will have to make a very similar additions in this class to those you have just made to Taxi. -The original getStatus method of the Taxi/Shuttle class will be printed available if a taxi was available. -A new method is required in the Ezcab class. The idea is that a customer wants to book a shuttle or a taxi to a particular destination. The destination is passed as a parameter to the method. -This method must return a Vehicle which is: Either: a shuttle whose next stop (i.e., destination) is where the customer wants to go, or a taxi that is free (i.e., has a null destination). If no suitable shuttle is available, and no taxi is free, then this method should return “Not available” or you can also take a isAvailable as boolean variable setting it to true or false. -A customer will always prefer a suitable shuttle because they are cheaper so if there is a suitable shuttle then that must be returned. It is important to be able to distinguish between a shuttle whose next destination may not be the customers destination, whereas for the taxi that is already booked to go directly to the destination. -Payment interface will deal with fare amounts for taxis and shuttle. Its dependant on the destinations. Include methods getFare() for a customer and display the total fare -Test all methods in TestMain class.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Computer Science
There are clearly some similarities in the implementations of Taxi and Shuttle that suggest use of inheritance to represent them. Introducing inheritance is the primary task of this assessment.
-The Ezcab class, The Ezcab class maintains separate lists of taxis and shuttles and destinations with destination fares (you can hardcode destination fares). It has a lookup method that searches for a taxi/shuttle with a given ID.
-The Taxi and Shuttle classes share some common attributes – location and destination. They also have some common methods – getLocation, getDestination, getStatus and setDestination.
-Vehicle is the superclass of both Taxi and Shuttle. This class involves placing the common fields and methods into Vehicle and removing them from Taxi and Shuttle.
-Modify Taxi and Shuttle class to indicate that it is a subclass of Vehicle. You can keep the id field in Vehicle class and getId,SetId methods.
-Arrange for Taxi's constructor to call the constructor of Vehicle so that a value for id is passed.
-In the Shuttle class, Make Shuttle a subclass of Vehicle. You will have to make a very similar additions in this class to those you have just made to Taxi. -The original getStatus method of the Taxi/Shuttle class will be printed available if a taxi was available.
-A new method is required in the Ezcab class. The idea is that a customer wants to book a shuttle or a taxi to a particular destination. The destination is passed as a parameter to the method.
-This method must return a Vehicle which is: Either: a shuttle whose next stop (i.e., destination) is where the customer wants to go, or a taxi that is free (i.e., has a null destination). If no suitable shuttle is available, and no taxi is free, then this method should return “Not available” or you can also take a isAvailable as boolean variable setting it to true or false.
-A customer will always prefer a suitable shuttle because they are cheaper so if there is a suitable shuttle then that must be returned. It is important to be able to distinguish between a shuttle whose next destination may not be the customers destination, whereas for the taxi that is already booked to go directly to the destination.
-Payment interface will deal with fare amounts for taxis and shuttle. Its dependant on the destinations. Include methods getFare() for a customer and display the total fare
-Test all methods in TestMain class.
Step by step
Solved in 3 steps