Before jumping into the code, learn one approach to simulating a print queue system by creating printer and job objects that coordinate with the queue class.
(light music)…- [Instructor] Now I'll share the approach I took to solve…the queues challenge.…For the PrintQueue class, I made that identical…to the data structure we created in our queue chapter.…I knew that the job class should have information…about how many pages are left in the job.…If I printed a page from the job,…I decremented the page count.…When the job got to a point where it had zero pages,…I knew that printing was complete.…As for the printer class, I knew it should carry…information about the job that it was working on,…I also knew that I was going to have to figure out how…to make the classes talk to each other because the printer…needed to get the next job by dequeueing from a non-empty…PrintQueue object.…
Another example of how I needed to get the classes…to talk to each other was that I knew I would need…to use job.print_page and job.check_complete…within my printer class.…Let's take a look at the code I wrote to make…all of this happen.…
- Abstract types and data structures
- Stacks as a linear abstract data type
- Creating the Stack class and its methods
- Adding items to the top and bottom of a stack
- Creating the Queue class and its methods
- Manipulating items in a queue
- Creating the Dequeue class and its methods
- Adding and removing items from a dequeue
Skill Level Advanced
Learning the Python 3 Standard Librarywith Kathryn Hodge2h 9m Intermediate
What you should know1m 26s
1. Abstract Data Types and Data Structures
2. The Stack
3. The Queue
4. The Deque
Next steps1m 43s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.