From the course: Programming Foundations: Object-Oriented Design
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Static attributes and methods - Python Tutorial
From the course: Programming Foundations: Object-Oriented Design
Static attributes and methods
- When we instantiate a bunch of enemy spaceships for our game, we'll want each of those spaceship objects to keep track of its own remaining shield strength independent of the others. That way, if the player's asteroid smashes into one of the ships, it'll reduce its shield strength, while the other ships remain unaffected. We've accomplished that by storing the ship's shield strength as an instance variable, which means each instance of the spaceship class will have its own separate copy. - What do you think about adding a different difficulty setting to our game? We could scale the toughness of all the ships, making their shields easier or harder to destroy. - Sounds good to me. - But unlike shield strength, the spaceships' toughness value should not vary from ship to ship. If the player decides to increase or decrease the game's difficulty, then all of the ships should increase or decrease their toughness the same…
Contents
-
-
-
-
-
-
-
(Locked)
Creating class diagrams: Attributes2m 23s
-
(Locked)
Creating class diagrams: Behaviors3m 9s
-
(Locked)
Converting class diagrams into code4m 29s
-
(Locked)
Instantiating classes3m 38s
-
(Locked)
Class with multiple constructors2m 29s
-
(Locked)
Static attributes and methods4m 19s
-
(Locked)
Challenge: Jukebox class diagrams1m 18s
-
(Locked)
Solution: Jukebox class diagrams5m 5s
-
(Locked)
-
-
-
-