Python - Encapsulation
Code Life
By Pierre Marsaa
The Problem
Right now, anyone can change any attribute directly. What if someone sets HP to -500? Or changes the name to an empty string? That could break your game!
↗️
Loading editor...
↶
↷
Oops! A Codémon with -500 HP doesn't make sense. Encapsulation is about controlling how attributes are accessed and modified.
Verify