Advertisement
Brainsucker

Untitled

Sep 5th, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. class QueueManager(list):
  2.     def __init__(self, max_queue_length=3):
  3.         self.max_queue_length = max_queue_length
  4.        
  5.         list.__init__(self)
  6.        
  7.     def isFull(self):
  8.         return len(self) == self.max_queue_length
  9.        
  10.        
  11.     def append(self, item):
  12.         if self.isFull():
  13.             raise IndexError, 'Maximum queue length reached.'
  14.            
  15.         if item in self:
  16.             raise ValueError, 'This value is already listed.'
  17.            
  18.         return list.append(item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement