Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part A Please use the starter file as a hint file Complete the classes for ArraySet and LinkedSet, so they use inheritance to maximum advantage.

Part A
Please use the starter file as a hint file
Complete the classes for ArraySet and LinkedSet, so they use inheritance to maximum advantage.
Notes for Problem1
Use starter file for the
arraysortedbag.py,
linkedbag.py and
abstractbag.py files. In the ArraySet class of the
arrayset.py file, complete the following: Import the ArrayBag class from the
arraybag.py file. Modify the so that it contains the contents of sourceCollection from the ArrayBag class, if it's present. Modify the add() method so that it uses the add() method from ArrayBag if an item is not present. Remove any methods that are redundant from the ArraySet class. In the LinkedSet class of the
linkedset.py file, complete the following: Import the LinkedBag class from the
linkedbag.py file. Modify the _init_so that it contains the contents of sourceCollection from the LinkedBag class, if it's present. Modify the add() method so that it uses the add() method from LinkedBag if an item is not present.
Remove any methods that are redundant from the LinkedSet class. Be sure to retain in the ArraySet and LinkedSet class only those methods that cannot be moved to their parent class. To test your program run the test() method in the
testset.py file.Complete the new class for sorted sets.
2. Complete the new class for sorted sets.
Notes for Problem2
Be sure to reuse your solution from Problem1 as your starter file for the
arraysortedbag.py,
linkedbag.py,
abstractbag.py,
arrayset.py and linke
dset.py files. Define def _(self, sourceCollection = None):
Define def add(self, item): To test your program run the run() method in the
testset.py file.
Part B
Problem 1
Write a class named Car that has the following data attributes:
__year_model (for the car's year model)
__ make (for the make of the car)
__speed (for the car's current speed)
The Car class should have an method that accepts the car's year model and make as arguments. These values should be assigned to the object's __year_model and __make data attributes. It should also assign 0 to the __speed data attribute.
The class should also have the following methods:
accelerate
The accelerate method should add 5 to the speed data attribute each time it is called.
brake
The brake method should subtract 5 from the speed data attribute each time it is called.
get_speed
The get_speed method should return the current speed.
Next, design a program that creates a Car object then calls the accelerate method five times. After each call to the accelerate method, get the current speed of the car and display it. Then call the brake method five times. After each call to the brake method, get the current speed of the car and display it.
Problem 2
Write a class named Patient that has attributes for the following data:
First name, middle name, and last name

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How do you convert benzene to acetonitrile?

Answered: 1 week ago

Question

Classify delivery styles by type.

Answered: 1 week ago