Question 3 (a) Design and implement a class called TaxiFare that includes the following instance variable(s) and methodis) for an object. Attribute(s)/instance variable(s): • taxilD is the unique ID number for the taxi involved in the fare (default value "000") • operator is the name of the driver (or boat operator) of the taxi (default value "unknown") The class definition should also include the following method(s): • a constructor/initializer method to initialize the instance variables; be sure to include the default values • accessor methods for each of the instance variables • a computeCharges method that returns O for this base class (to allow for method overriding and polymorphism) • special methodstr_() to print the required information as shown in the sample output, including the taxi ID, the operator and the cost of the ride, with appropriate descriptive labels

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
The class definition should also include the following method(s):
a constructor/initializer method to initialize the instance variables; be sure to include the default
values
• accessor methods for the instance variable
a computeCharges method that returms the total charges for the chartered water taxi fare, using
the instance variables and the constant class variables and the computeCharges method from its
parent class; recall that an invalid or default destination should return a charge of 0
• compute and print the total fares (charges) collected for all fare objects in the list, with appropriate
labels
Sample data/output:
:
Taxi ID: 222
• special method_str_) to print the required information as shown in the sample output,
including the taxi ID, the operator, the cost of the ride, and the destination, with appropriate
descriptive labels
Operator: Leah
Charges: $0.00
Таxi ID: з3
Operator: Rae
Charges: $40.88
Question 3 (e)
Test the defined class by performing the following operations in a main function:
create a list containing at least one or two of each type of object (TaxiFare, CabFare,
Num KMs: 20.5
Wait Time: 10
WaterTaxiFare, CharterWaterFare); also include an extra CharterWaterFare object
with an invalid destination
Taxi ID: 444
print each of the list objects using the special_str_) method on each object
Operator: Skipper
Charges: $52.50
Num Tickets: 15
Cost Per Iicket: $3.50
Taxi ID: 555
Operator: Nate
Charges: $73.00
Num Tickets: 10
Cost Per Ticket: $2.50
compute and print the total fares (charges) collected for all fare objects in the list, with appropriate
labels
Destination: D3
Sample data/output:
Taxi ID: 777
Operator: Bob
Charges: $0.00
Num Tickets: 5
Cost Per Iicket: $1.50
Taxi ID: 222
Operator: Leah
Charges: $0.00
Таxi ID: 333
Destination: D5
Operator: Rae
Charges: $40.88
Num KMs: 20.5
Total Fares Collected: $166.38
Wait Time: 10
After completing Part A and Part B, please complete the associated quiz, once it becomes available:
Assignment 4 Quiz
Тахі ID: 444
Operator: Skipper
Charges: $52.50
Num TicketR: 15
Transcribed Image Text:The class definition should also include the following method(s): a constructor/initializer method to initialize the instance variables; be sure to include the default values • accessor methods for the instance variable a computeCharges method that returms the total charges for the chartered water taxi fare, using the instance variables and the constant class variables and the computeCharges method from its parent class; recall that an invalid or default destination should return a charge of 0 • compute and print the total fares (charges) collected for all fare objects in the list, with appropriate labels Sample data/output: : Taxi ID: 222 • special method_str_) to print the required information as shown in the sample output, including the taxi ID, the operator, the cost of the ride, and the destination, with appropriate descriptive labels Operator: Leah Charges: $0.00 Таxi ID: з3 Operator: Rae Charges: $40.88 Question 3 (e) Test the defined class by performing the following operations in a main function: create a list containing at least one or two of each type of object (TaxiFare, CabFare, Num KMs: 20.5 Wait Time: 10 WaterTaxiFare, CharterWaterFare); also include an extra CharterWaterFare object with an invalid destination Taxi ID: 444 print each of the list objects using the special_str_) method on each object Operator: Skipper Charges: $52.50 Num Tickets: 15 Cost Per Iicket: $3.50 Taxi ID: 555 Operator: Nate Charges: $73.00 Num Tickets: 10 Cost Per Ticket: $2.50 compute and print the total fares (charges) collected for all fare objects in the list, with appropriate labels Destination: D3 Sample data/output: Taxi ID: 777 Operator: Bob Charges: $0.00 Num Tickets: 5 Cost Per Iicket: $1.50 Taxi ID: 222 Operator: Leah Charges: $0.00 Таxi ID: 333 Destination: D5 Operator: Rae Charges: $40.88 Num KMs: 20.5 Total Fares Collected: $166.38 Wait Time: 10 After completing Part A and Part B, please complete the associated quiz, once it becomes available: Assignment 4 Quiz Тахі ID: 444 Operator: Skipper Charges: $52.50 Num TicketR: 15
accessor methods for each of the instance variables
A local taxi company has decided to expand and not only have taxis that go on land (i.e., cars), but also
taxis that go on water (i.e., boats). You have been asked to design a number of classes to represent the
various taxi fares (trips with passengers) and their various fee structures, by using inheritance in
Python.
a computeCharges method that returns the total charges for the cab fare, using the instance
variables and the defined constants (i.e., kms multiplied by the cost per km, plus minutes multiplied
by the cost per minute)
Please read all parts of this question below before starting the question. Include the completed code for all
parts of this question in a file called taxi_company.py-
NOTE: To implement encapsulation, all of the instance variables/fields should be considered private.
Question 3 (a)
Design and implement a class called TaxiFare that includes the following instance variable(s) and
method(s) for an object.
special method_str_() to print the required information as shown in the sample output,
including the taxi ID, the operator, the cost of the ride, the number of kilometres and the number
of minutes of wait time, with appropriate descriptive labels
Attribute(s)/instance variable(s):
• taxilD is the unique ID number for the taxi involved in the fare (default value "000")
• operator is the name of the driver (or boat operator) of the taxi (default value "unknown")
Question 3 (c)
Extend the design of the class in Question 3 (a) to include a subclass of the TaxiFare class, called
WaterTaxiFare, that creates an object with the following additional characteristics:
• numTickets is the number of tickets sold for the fare, one per passenger (default value 0)
• costPerTicket is the charge for riding the water taxi, per ticket (default value 0.0)
The class definition should also include the following method(s):
• a constructor/initializer method to initialize the instance variables; be sure to include the default
values
• accessor methods for each of the instance variables
a computeCharges method that returns 0 for this base class (to allow for method overriding and
polymorphism)
special method_str_() to print the required information as shown in the sample output,
including the taxi ID, the operator and the cost of the ride, with appropriate descriptive labels
The class definition should also include the following method(s):
• a constructor/initializer method to initialize the instance variables; be sure to include the default
values
• accessor methods for each of the instance variables
a computeCharges method that returns the total charges for the water taxi fare, using the instance
variables (i.e., number of tickets multiplied by the cost per ticket)
Question 3 (b)
Extend the design of the class in Question 3 (a) to include a subclass of the TaxiFare class, called
• special method_
_str_() to print the required information as shown in the sample output,
including the taxi ID, the operator, the cost of the ride, the number of tickets and the cost per
ticket, with appropriate descriptive labels
CabFare, that creates an object with the following additional characteristics:
• meteredKMs is the number of kilometres that the taxicab travelled to the final destination (default
value of 0.0)
• waitTime is the number of minutes that the taxicab had to wait for the passenger (default value of
Question 3 (d)
Extend the design of the class in Question 3 (c) to include a subclass of the WaterTaxiFare class,
called CharterWaterFare, that creates an object with the following additional characteristics:
• destination is the chosen destination of the passenger(s) who have chartered the water taxi; there
are three possible destinations, D1, D2 or D3 (default value "N/A")
0)
Two constant class variables should be defined to hold the cost per kilometre and the cost per minute
of wait time for the fare, as $1.75 and $0.50, respectively.
Three constant class variables should be defined to hold the cost to charter the water taxi to each of
the three destinations. The cost of D1 is $25.50, D2 is $33.75 and D3 is $48.00. If an invalid
destination is entered (or the default value is used) then the cost should be $0.
The class definition should also include the following method(s):
a constructor/initializer method to initialize the instance variables; be sure to include the default
values
Transcribed Image Text:accessor methods for each of the instance variables A local taxi company has decided to expand and not only have taxis that go on land (i.e., cars), but also taxis that go on water (i.e., boats). You have been asked to design a number of classes to represent the various taxi fares (trips with passengers) and their various fee structures, by using inheritance in Python. a computeCharges method that returns the total charges for the cab fare, using the instance variables and the defined constants (i.e., kms multiplied by the cost per km, plus minutes multiplied by the cost per minute) Please read all parts of this question below before starting the question. Include the completed code for all parts of this question in a file called taxi_company.py- NOTE: To implement encapsulation, all of the instance variables/fields should be considered private. Question 3 (a) Design and implement a class called TaxiFare that includes the following instance variable(s) and method(s) for an object. special method_str_() to print the required information as shown in the sample output, including the taxi ID, the operator, the cost of the ride, the number of kilometres and the number of minutes of wait time, with appropriate descriptive labels Attribute(s)/instance variable(s): • taxilD is the unique ID number for the taxi involved in the fare (default value "000") • operator is the name of the driver (or boat operator) of the taxi (default value "unknown") Question 3 (c) Extend the design of the class in Question 3 (a) to include a subclass of the TaxiFare class, called WaterTaxiFare, that creates an object with the following additional characteristics: • numTickets is the number of tickets sold for the fare, one per passenger (default value 0) • costPerTicket is the charge for riding the water taxi, per ticket (default value 0.0) The class definition should also include the following method(s): • a constructor/initializer method to initialize the instance variables; be sure to include the default values • accessor methods for each of the instance variables a computeCharges method that returns 0 for this base class (to allow for method overriding and polymorphism) special method_str_() to print the required information as shown in the sample output, including the taxi ID, the operator and the cost of the ride, with appropriate descriptive labels The class definition should also include the following method(s): • a constructor/initializer method to initialize the instance variables; be sure to include the default values • accessor methods for each of the instance variables a computeCharges method that returns the total charges for the water taxi fare, using the instance variables (i.e., number of tickets multiplied by the cost per ticket) Question 3 (b) Extend the design of the class in Question 3 (a) to include a subclass of the TaxiFare class, called • special method_ _str_() to print the required information as shown in the sample output, including the taxi ID, the operator, the cost of the ride, the number of tickets and the cost per ticket, with appropriate descriptive labels CabFare, that creates an object with the following additional characteristics: • meteredKMs is the number of kilometres that the taxicab travelled to the final destination (default value of 0.0) • waitTime is the number of minutes that the taxicab had to wait for the passenger (default value of Question 3 (d) Extend the design of the class in Question 3 (c) to include a subclass of the WaterTaxiFare class, called CharterWaterFare, that creates an object with the following additional characteristics: • destination is the chosen destination of the passenger(s) who have chartered the water taxi; there are three possible destinations, D1, D2 or D3 (default value "N/A") 0) Two constant class variables should be defined to hold the cost per kilometre and the cost per minute of wait time for the fare, as $1.75 and $0.50, respectively. Three constant class variables should be defined to hold the cost to charter the water taxi to each of the three destinations. The cost of D1 is $25.50, D2 is $33.75 and D3 is $48.00. If an invalid destination is entered (or the default value is used) then the cost should be $0. The class definition should also include the following method(s): a constructor/initializer method to initialize the instance variables; be sure to include the default values
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY