Learn from this video how to write the code for the suggested approach to solving the print queue challenge.
(gentle echoing snares)…- [Narrator] I'm going to run my file interactively,…so that I can play around with the classes I made.…(keyboard clicking)…The first thing I want to do is I want to create…an object for each of the classes.…So, first I'll create a job,…I'll just call it job1.…And then I'll create a print queue…and I'll call that print_q,…and that will be an instance of my PrintQueue object.…
And lastly I'll create a printer,…or a printer instance, called printer.…Okay, the first thing I need to do is…I need to get that job1 into my PrintQueue…'cause right now my queue doesn't have anything in it,…so all of the methods I wrote aren't super useful.…In order to get something into my queue,…I need to enqueue an item into it.…Now because PrintQueue,…or print_q, is a PrintQueue object,…I have the enqueue method available to me.…
So, if I call the enqueue method on PrintQueue…and I pass in the item, which is job1,…so I'm passing in an entire job object to my PrintQueue,…I now have something in my PrintQueue…and I can test that out by looking at the items attribute,…
- 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.