I’m struggling to fully grasp the concepts of getters and setters. My understanding is that ‘get’ are methods to return values stored in the object without mutating or altering the values and ‘set’ are methods for altering the values in the object, even though you can alter the values directly.

This exercise instructs us to create getters and setters for each of the _courses but it doesn’t seem like these methods are ever called in the program. My output is correct whether I have the get and set methods or not.

So what’s the purpose?

I thought the same thing when I did the Meal Maker project. After passing all of the requirements, I went back and fully implemented the getters and setters, and wrote code to test them. Seemed like a big waste to define methods that are never invoked. Many people get confused with this project as it is without the additional confusion of coding getters and setters that are never used. Maybe someday the lesson will be updated.

1 Like

Yes,they sound confusing at first but they do have fantastic use cases -
First read about Flags and Descriptors,Then read this Getters and Setters.

Hope it helps!