Create a base class called Vehicle with name, max_speed, and tank_size attributes. Then create a derived class called Truck that inherits from the Vehicle class. The Truck should have an additional attribute called seating_capacity with default value of 5. The child class should have a method named range to calculate fuel efficiency - the calculation should be: max_speed * seating_capacity * tank_size. Override the method such that it can accept 1, 2 or 3 positional arguments.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a base class called Vehicle with name, max_speed, and tank_size attributes. Then create a derived class called Truck that inherits from the Vehicle class. The Truck should have an additional attribute called seating_capacity with default value of 5. The child class should have a method named range to calculate fuel efficiency - the calculation should be: max_speed * seating_capacity * tank_size. Override the method such that it can accept 1, 2 or 3 positional arguments. 

Attached is my following code, also attached is a method for override method. Need help implementing the override method for the range to calculate the fuel effiency.

class Vehicle:
name="
max_speed
tank size
=D0
def
int
(self, name,max_speed,tank_size):
self.name = name
self.max_speed = max_speed
self.tank_size = tank_size
class Truck (Vehicle) :
seating_capacity = 5
(self, name,max_speed, tank_size,seating_capacity):
(name, max_speed, tank_size)
def
init
super ()._init
self.seating_capacity = seating_capacity
Transcribed Image Text:class Vehicle: name=" max_speed tank size =D0 def int (self, name,max_speed,tank_size): self.name = name self.max_speed = max_speed self.tank_size = tank_size class Truck (Vehicle) : seating_capacity = 5 (self, name,max_speed, tank_size,seating_capacity): (name, max_speed, tank_size) def init super ()._init self.seating_capacity = seating_capacity
#Method overriding
class Account:
def sum(self, a=None, b=None, c=None):
total = 0
if a!=None and b!=None and c!=None:
total = a+b+c
elif a!=None and b!=None:
total = a+b
else:
total = a
return total
account1 = Account()
print(account1.sum(5, 4, 1))
Transcribed Image Text:#Method overriding class Account: def sum(self, a=None, b=None, c=None): total = 0 if a!=None and b!=None and c!=None: total = a+b+c elif a!=None and b!=None: total = a+b else: total = a return total account1 = Account() print(account1.sum(5, 4, 1))
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education