Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write an implementation that satisfies the doc - string in the last line using ONLY Pycharm, please. Thank you. class Registry ( object ) :
Write an implementation that satisfies the docstring in the last line using ONLY Pycharm, please. Thank you. class Registryobject: def initself size, value: Purpose: Initialize a registry of a give size filled with the given value Preconditions: size: number of elements in the registry value: the default initial value for all elements self.reg value for i in rangesize def setself i: Purpose: Set the registry element at i to True Preconditions: i: an index, in the correct range for reg Postconditions: the registry value at i is set to True Return: none self.regi True def resetself i: Purpose: Set the registry element at i to False Preconditions: i: an index, in the correct range for reg Postconditions: the registry value at i is set to False Return: none self.regi False def isregisteredself i: Purpose: Returns the value stored at registry element i Preconditions: i: an index, in the correct range for reg Postconditions: none Return: the value stored at element i return self.regi def showself: Purpose: Shows the current Registry values Preconditions: none Postconditions: none Returns: none printselfreg def extendself size, value: Purpose: Extend the registry. This grows the registry to the given size. The value given will be the new default value for the extended registers. Preconditions: size: number of elements in the registry value: the default initial value for all elements Postconditions: IMPORTANT: The previous entries in the registry retain their values. The registry is expanded. Entries up to the original size are kept the same. New entries are set to the value provided in the argument. Returns: none Warnings: This method asserts that the new size is greater than the original Registry size. assert size lenselfregError in Registry method extendsize value "Provided size must be greater than the original Registry size." # TODO your implementation here
Write an implementation that satisfies the docstring in the last line using ONLY Pycharm, please.
Thank you.
class Registryobject:
def initself size, value:
Purpose:
Initialize a registry of a give size filled with the
given value
Preconditions:
size: number of elements in the registry
value: the default initial value for all elements
self.reg value for i in rangesize
def setself i:
Purpose:
Set the registry element at i to True
Preconditions:
i: an index, in the correct range for reg
Postconditions:
the registry value at i is set to True
Return:
none
self.regi True
def resetself i:
Purpose:
Set the registry element at i to False
Preconditions:
i: an index, in the correct range for reg
Postconditions:
the registry value at i is set to False
Return:
none
self.regi False
def isregisteredself i:
Purpose:
Returns the value stored at registry element i
Preconditions:
i: an index, in the correct range for reg
Postconditions:
none
Return:
the value stored at element i
return self.regi
def showself:
Purpose:
Shows the current Registry values
Preconditions:
none
Postconditions:
none
Returns:
none
printselfreg
def extendself size, value:
Purpose:
Extend the registry. This grows the registry to the given size.
The value given will be the new default value for the extended registers.
Preconditions:
size: number of elements in the registry
value: the default initial value for all elements
Postconditions:
IMPORTANT: The previous entries in the registry retain their values.
The registry is expanded. Entries up to the original size are kept the same.
New entries are set to the value provided in the argument.
Returns:
none
Warnings:
This method asserts that the new size is greater than the original Registry size.
assert size lenselfregError in Registry method extendsize value
"Provided size must be greater than the original Registry size."
# TODO your implementation here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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