Question: Queue class ( 1 5 marks ) Implement the Queue class in the file queue.py . Your queue must be an array - based dynamic
Queue class marks
Implement the Queue class in the file
queue.py Your queue must be an arraybased
dynamic circular queue. You must use numpy arrays with object type elements for the
underlying data structure. Except for
which must run in time, each other
method must run in constant time and the Queue class must implement the
it
enqueue, dequeue, peek, isempty.
repr
len
methods. If
dequeue and peek are called when a queue is empty, the methods should raise an
Empty exception.
Testing marks
Write unit test cases to test your Queue class and save them in testqueue.py Test each
method carefully, including testing for the Empty exception.
Printer Simulation marks
Implement the Printer class and the following methodsfunctions and save them in the file
printersim.py
Printer class marks
This class represents a printer and has the following methods:
init
self name: Create a printer object with the given name. Besides having a
name, a printer needs to keep track of the number of pages to print and the total
number of pages already printed.
self: Return the information about a printer using the following format:
"Printer: name Pages to print: the number of pages to print Total pages printed: the
total number of pages printed
isreadyself: Return True if a printer is ready to accept a print request ie the
number of pages to print is zero Otherwise, it should return False.
printself: Simulate printing a single page. This method should decrement the number
of pages to print and increment the total number of pages printed.
acceptself pages: Accept a print request pages indicate the number of pages to
print A printer can only accept a print request if it's ready.
printersimulation function marks
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
