Join Barron Stone for an in-depth discussion in this video Inheriting classes, part of Programming Fundamentals in the Real World.
- View Offline
- Exercise Files
- When creating new classes,…we can pass on attributes and methods…from other existing classes…through a process called inheritance.…This is useful when creating a new class…which represents a specific subset…of a previously defined more generic class.…To demonstrate this concept, let's go out to the garage.…Say I create a class called vehicle…which contains attributes and methods…that are common to all types of vehicles.…All vehicles can be described in terms of color,…so my class will have a color attribute.…
Also, all vehicles are manufactured by somebody…so I'll create another data field to store that information.…Finally, although it may not be the case for much longer,…my vehicles run on gasoline so I'll need a data field…for the level of fuel in the tank.…As far as methods go, for any vehicle to be useful,…I need to be able to drive it.…So we'll define a drive method.…And when I use the drive method, it'll act upon that vehicle…by decreasing the amount of gas in the tank.…Now, this vehicle class that I just described…
- Reusing functions
- Local vs. global variables
- Creating and naming custom objects
- Class inheritance
- Modules and packages
- Multidimensional lists and tuples
- Queues and stacks
- Creating and combining sets
- Storing data in dictionaries
- If/else and switch statements
- For vs. while loops
- Error handling
- Polling and event-driven programming
Skill Level Beginner
Foundations of Programming: Design Patternswith Elisabeth Robson2h 19m Intermediate
3. Class Inheritance
4. Modules and Packages
5. Lists and Tuples
6. Queues and Stacks
9. Conditional Execution
11. Error Handling
12. Polling and Event-Driven Programming
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
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.