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 (15 marks)
Implement the Queue class in the file
queue.py. Your queue must be an array-based
dynamic circular queue. You must use numpy arrays with object type elements for the
underlying data structure. Except for
which must run in O(n) time, each other
method must run in constant time O(1), and the Queue class must implement the
it_
, enqueue, dequeue, peek, is_empty.
repr
len
methods. If
dequeue and peek are called when a queue is empty, the methods should raise an
Empty exception.
Testing (15 marks)
Write unit test cases to test your Queue class and save them in test_queue.py. Test each
method carefully, including testing for the Empty exception.
Printer Simulation (70 marks)
Implement the Printer class and the following methods/functions and save them in the file
printersim.py.
Printer class (20 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]."
is_ready(self): Return True if a printer is ready to accept a print request (i.e., the
number of pages to print is zero). Otherwise, it should return False.
print(self): Simulate printing a single page. This method should decrement the number
of pages to print and increment the total number of pages printed.
accept(self, 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.
printer_simulation() function (50 marks)
Queue class ( 1 5 marks ) Implement the Queue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!