Answered step by step
Verified Expert Solution
Link Copied!

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 doc-string in the last line using ONLY Pycharm, please.
Thank you.
class Registry(object):
def __init__(self, size, value):
"""
Purpose:
Initialize a registry of a give size filled with the
given value
Pre-conditions:
size: number of elements in the registry
value: the default initial value for all elements
"""
self.__reg =[value for i in range(size)]
def set(self, i):
"""
Purpose:
Set the registry element at i to True
Pre-conditions:
i: an index, in the correct range for reg
Post-conditions:
the registry value at i is set to True
Return:
(none)
"""
self.__reg[i]= True
def reset(self, i):
"""
Purpose:
Set the registry element at i to False
Pre-conditions:
i: an index, in the correct range for reg
Post-conditions:
the registry value at i is set to False
Return:
(none)
"""
self.__reg[i]= False
def is_registered(self, i):
"""
Purpose:
Returns the value stored at registry element i
Pre-conditions:
i: an index, in the correct range for reg
Post-conditions:
(none)
Return:
the value stored at element i
"""
return self.__reg[i]
def show(self):
"""
Purpose:
Shows the current Registry values
Pre-conditions:
(none)
Post-conditions:
(none)
Returns:
(none)
"""
print(self.__reg)
def extend(self, 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.
Pre-conditions:
size: number of elements in the registry
value: the default initial value for all elements
Post-conditions:
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 > len(self.__reg),("Error in Registry method extend(size, 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

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions