Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Read the docstring for remove, delete the raise statement, then implement the method. This method should reduce the bag s capacity when two - thirds
Read the docstring for remove, delete the raise statement, then implement the method. This
method should reduce the bags capacity when twothirds or more of the backing array is not used.
Hint: see class ArrayList.
Note that:
When the bag is empty, the method should raise a ValueError exception that displays the
message, "bag.removex: remove from empty bag". The statement that does this is:
Lab : Array Bag SYSC
Carleton University Systems and Computer Engineering
raise ValueErrorbagremovex: remove from empty bag"
When the bag has no occurrences of the item we want to remove, the method should raise a
ValueError exception that displays the message, "bag.removex: x not in bag"
Use the Python shell to run a few tests on remove.
Think about the test cases that would be required to thoroughly test remove. Implement these
test cases as methods in class RemoveTestCase. Dont delete test remove and test remove
Run the test script and review the output in the shell window. If necessary, edit remove and rerun
the test script until all test cases pass.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started