Question: 1. Class Implementation a) Implement a class Vehicle with a single attribute type. b) Implement an init method with an optional parameter type. Set the

 1. Class Implementation a) Implement a class Vehicle with a single
attribute type. b) Implement an init method with an optional parameter type.

1. Class Implementation a) Implement a class Vehicle with a single attribute type. b) Implement an init method with an optional parameter type. Set the default value of the attribute type to "unknown". c) Implement a print method to display: type value d) Instantiate two objects of type Vehicle, one with an argument one without. e) Print both objects. Output Example type unknown type-Car 2. Inheritance a) Add the code from problem 1 to a new file. b) Implement a class car that inherits from the class Vehicle c) The Car class has a single local attribute name. d) Implement an init method with an optional parameter name. Set the default value of the inherited attribute type to "Car". Set the default value of the attribute name to "unknown". e) Override the print function for car to display: type-value name value 1) Instantiate two objects of type Car, one with an argument, one without. g) Print both objects. Output Example type-Car name=unknown type-Car name-Audi 3. Composition a) Add the code from problem 2 to a new file. b) Implement a class Engine. c) The Engine class has a single attribute horsepower. d) Implement an init method with an optional parameter horsepower. Set the default value of the inherited attribute type to 0. e) Implement a getHorse Power method in the Engine class which returns the value of the attribute horsepower. f) Update the car print method so that it calls the getHorse Power method and displays: type-Car name value horsepower-value g) Instantiate a Car that is an Audi with 450 horsepower. h) Call the car print method. Output Example type=Car name Audi engine 450 4. Class Data a) Implement a class Student with two attributes, name and an empty list grades. b) Implement a print method that displays attribute data as follows: Name: April Grades: 89 93 95 c) Implement an addGrade method which adds an integer grade to the grades. d) Implement an remove Grade method which removes a grade from grades in: 1. the list grades contains at least one grade 2. the specified grade is in the list grades. e) Instantiate a Student object. t Use the addGrade thethod to add four grades to the list grades g) Use the remove Grade method to remove a grade. Output Example name: April Bradent90 82 85

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!