Python 3 Problem: I hope you can help with this please answer the problem using python 3. Thanks!
Code the program below . The program must contain and use a main
function that is called inside of:
If __name__ == “__main__”:
Create the abstract base class Vehicle with the following attributes:
| Variables | Methods |
| Manufacturer Model Wheels TypeOfVehicle Seats |
printDetails() - ABC |
The methods with ABC next to them should be abstracted and overloaded in the child class
Create three child classes:
Car
| Variables | Methods |
| ManufacturingNumber | printDetails() |
Truck
| Variables | Methods |
| ManufacturingNumber | printDetails() |
Motorcycle
| Variables | Methods |
| ManufacturingNumber | printDetails() |
In the __init__ methods of each child class, print out what kind of vehicle was created
IE: If a Car is created, print “A car was created”
The printDetails() method should print out the Manufacturer,
Model, Wheels, TypeOfVehicle, Seats and
ManufacturingNumber.
Example:
Manufacturer: Toyota
Model: Linux
Wheels: 4
Type of Vehicle: Truck
Seats: 4
Manufacturing Number: 33
The checkInfo() method should allow a user to input data with a
keyword related to each variable and
check if the entered data matches the variable in the object,
printing the variable name along with True
or False
IE: object.checkInfo(Seats=5) should print Seats + True or False depending on whether self.seats is 5
In your main function create the following:
- A list that contains five manufacturers
- A dict that contains the three types of vehicles as keys, each
with a list of three different models under each
- A dict that contains the three types of vehicles as keys, each
with a list of the number of seats that could be in each vehicle
type (Car could have 2 to 5, Truck could have 2 to 4, Motorcycle
could have 1 to 2)
- Create a dict called totals that contains the three types of
vehicles as keys, each set to equal 0
Ex.
manufacturers = ['Toyota','GM','Ford','Jeep','Audi']
models = {'Car':['X11','i3','XFCE'], 'Truck':["Linux", "Unix",
"FreeBSD"], 'Motorcycle':["Triforce",
"Mushroom", "Morphball"]}
With the above list and dicts, create a blank list and populate
it with 100 instances of Cars, Trucks, and
Motorcycles that all contain randomly selected data
, increasing the respective totals key by 1 each
time. The ManufacturingNumber should be equal to the current totals
key
With the list of 100 vehicles, loop through all of them and call the printDetails() method for each one.
At the end of the loop print out the total amount of each vehicle created
Finally, take two of the vehicles in the list
and call their checkInfo() methods, passing to
them respective
random options from the pools of data you created at the start.
Ex. Output for checkinfo()
Manufacturer: True or False
Model: True or False
Wheels: True or False
Seats: True or False
CODE:
from random import randint
class Vehicle:
# constructor
def __init__(self, manufacturer, model, wheels, vechicleType, seats):
self.Manufacturer = manufacturer
self.Model = model
self.Wheels = wheels
self.TypeOfVehicle = vechicleType
self.Seats = seats
# abstract method
def printDetails(self):
pass
# to check the information
def checkInfo(self, **kwargs):
for key, value in kwargs.items():
# because we need to check with the class variables in a generalized manner
s="self."+key
if eval(s)==value:
print(key,"True")
else:
print(key, "False")
# class car
class Car(Vehicle):
# constructor
def __init__(self,manufacturer,model,wheels,vechicleType,seats,ManufacturingNumber):
print("A car is created")
self.ManufacturingNumber = ManufacturingNumber
# calling parent class with required arguments to instantiate the object
super(Car, self).__init__(manufacturer,model,wheels,vechicleType,seats)
def printDetails(self):
print("\n\nManufacturer: ", self.Manufacturer)
print("Model: ",self.Model)
print("Wheels: ",self.Wheels)
print("Type of vehicle: ",self.TypeOfVehicle)
print("Seats: ", self.Seats)
print("Manufacturing Number: ", self.ManufacturingNumber)
class Truck(Vehicle):
def __init__(self, manufacturer, model, wheels, vechicleType, seats, ManufacturingNumber):
print("A Truck is created")
self.ManufacturingNumber = ManufacturingNumber
# calling parent class with required arguments to instantiate the object
super(Truck, self).__init__(manufacturer, model, wheels, vechicleType, seats)
def printDetails(self):
print("\n\nManufacturer: ", self.Manufacturer)
print("Model: ", self.Model)
print("Wheels: ", self.Wheels)
print("Type of vehicle: ", self.TypeOfVehicle)
print("Seats: ", self.Seats)
print("Manufacturing Number: ",self.ManufacturingNumber)
class Motorcycle(Vehicle):
def __init__(self,manufacturer,model,wheels,vechicleType,seats,ManufacturingNumber):
print("A Motorcycle is created")
self.ManufacturingNumber = ManufacturingNumber
# calling parent class with required arguments to instantiate the object
super(Motorcycle, self).__init__(manufacturer, model, wheels, vechicleType, seats)
def printDetails(self):
print("\n\nManufacturer: ", self.Manufacturer)
print("Model: ", self.Model)
print("Wheels: ", self.Wheels)
print("Type of vehicle: ", self.TypeOfVehicle)
print("Seats: ", self.Seats)
print("Manufacturing Number: ", self.ManufacturingNumber)
if __name__=='__main__':
# initializing all the lists and dict
manufacturers = ['Toyota', 'GM', 'Ford', 'Jeep', 'Audi']
models = {'Car': ['X11', 'i3', 'XFCE'], 'Truck': ["Linux", "Unix", "FreeBSD"], 'Motorcycle': ["Triforce","Mushroom","Morphball"]}
seats = {'Car': [2, 3, 4, 5], 'Truck': [2, 3, 4], 'Motorcycle': [1, 2]}
totals = {'Car': 0, 'Truck': 0, 'Motorcycle': 0}
l=[]
# change the value of n for number of object of each type
n=10
while n >= 0:
# def __init__(self,manufacturer,model,wheels,vechicleType,seats,ManufacturingNumber):
car = Car(manufacturers[randint(0, 4)], models['Car'][randint(0, 2)], 4, "Car", seats['Car'][randint(0, 3)], totals['Car'])
# appending the object to the list
l.append(car)
# increamenting the manufacturing number
totals["Car"] += 1
n -= 1
truck = Truck(manufacturers[randint(0, 4)], models['Truck'][randint(0, 2)], 8, "Truck", seats['Truck'][randint(0, 2)], totals['Truck'])
# increamenting the manufacturing number
totals["Truck"] += 1
# appending the object to the list
l.append(truck)
n -= 1
bike = Motorcycle(manufacturers[randint(0, 4)], models['Motorcycle'][randint(0, 2)], 4, "Motorcycle", seats['Motorcycle'][randint(0, 1)], totals['Motorcycle'])
# increamenting the manufacturing number
totals["Motorcycle"] += 1
# appending the object to the list
l.append(bike)
n -= 1
# printing all details
for i in l:
i.printDetails()
# checking info for 2 random vehicle object
print("\n\nChecking INFO:")
l[randint(0, len(l)-1)].checkInfo(Manufacturer="Toyota",Wheels=4,Model="XFCE",TypeOfVehicle="Car")
l[randint(0, len(l) - 1)].checkInfo(Manufacturer="Ford", Wheels=8)
OUTPUT:

Please upvote if you like my answer and comment below if you have any queries.
Python 3 Problem: I hope you can help with this please answer the problem using python...
Hello, please solve this problem for object oriented
programming in C++ program language. I have final tomorrow so it
will be very helpful. thank you.
PROBLEM 1: application that simulates the highway Create an In order to solve above mentioned requirements, it is necessary to implement several classes: 1. Class Vehicle contains information about the vehicles that drive on the highway. Each vehicle has information about its a Type (can be one of these: Motorcycle, Car, Truck) b. License number...
Python programming I need help with the following: Create a class Vehicle. The class should have name, weight, fuel, number of wheels and move attributes/methods. Create child class that are semi, car, sail boat and bicycle. Give the class the ability to have a constructor that sets the name. Have the other attributes hard coded to suit the vehicle. Give each a way of speaking their attributes as well as the type of animal. For example “Hi I am Lightening...
Hey guys I need help with this question with 3 sub-problems.
f test remove short synonyms () Define the remove shorti synonyms function which is passed a dictionary as a parameter- The keys of the parameter dictionary are words and the corresponding values are 1ists of synonyms (synonyms are words which have the same or nearly the same meaning). The function romoves all the eynonyme which have ous than 8 charactors from each corresponding list of synonyms-As well, the funet...
Given the information below, create the fully labeled Crow's Foot ERD using a specialization hierarchy where appropriate (use Visio). The ERD must contain all primary keys, foreign keys, and main attributes. Business rules are defined as follows: A company owns three types of vehicles: cars, trucks, and motorcycles. When delivered, each vehicle goes through inspection. Each vehicle creates one record in the INSPECTION table. One record in the INSPECTION table is related to one vehicle. All vehicles share common basic...
I need help with this problem. Using Python please. Thanks Construct a class “Monster” with the following attributes: self.name (a string) self.type (a string, default is ‘Normal’) self.current_hp (int, starts out equal to max_hp) self.max_hp (int, is given as input when the class instance is created, default is 20) self.exp (int, starts at 0, is increased by fighting) self.attacks (a dict of all known attacks) self.possible_attacks (a dictionary of all possible attacks The dictionary of possible_attacks will map the name...
Using Python.
You will create two classes and then use the provided test program to make sure your program works This means that your class and methods must match the names used in the test program You should break your class implementation into multiple files. You should have a car.py that defines the car class and a list.py that defines a link class and the linked list class. When all is working, you should zip up your complete project and...
Hi, please read the entire problem. I need help with the BusOrder class and test for it. In Java you will require the use of loops and decisions for the following scenario: Pretty Vehicles (PV) is a vehicle company that makes four different types of vehicles: cars, buses, motorcycles, and vans. Their management team got together and decided that you start working on a more serious software for their most profitable vehicles first - Cars and Busses. Your job now...
Hey guys I need help with this assignment. However it contains 7
sub-problems to solve but I figured only 4 of them can be solved in
one post so I posted the other on another question so please check
them out as well :)
Here is the questions in this assignment:
Note: Two helper functions Some of the testing codes for the functions in this assignment makes use of the print_dict in_key_order (a dict) function which prints dictionary keyvalue pairs...
7. Programming Problem: In this problem we are trying to model a repair service that can repair Cars and Computers. Even though the Car and Computer are different products, they have common repair methods that can be abstracted in an interface. Please complete the interface and the classes by adding the required methods, as per the problem description. Partially complete code is provided as shown below A. Create an interface called Mechanism. This interface has two methods. The first method...
Exercise 11 - in Java please complete the following:
For this exercise, you need to work on your own. In this exercise you will write the implementation of the pre-written implementation of the class CAR. The class CAR has the following data and methods listed below: . Data fields: A String model that stores the car model, and an int year that stores the year the car was built. . Default constructor . Overloaded constructor that passes values for both...