The first few things we learned about object oriented programming( OOP) were the basics. We were taught that object oriented programming was about creating something (an object) that is created by a class. If we were to create the object elevator, we'd need to have methods that take the elevator up and one that takes the elevator down. We could also have a method to call for help if there was an emergency. These methods help create this elevator and make the elevator an actual, functioning elevator. We also had to create an __init__ method for classes and this method helps to start up anything that we need prior to creating this object. For example, in the __init__ method for class elevator, we could create a list that would contain how many floors there are in the building. Then, the method for moving up can use this list to figure out if we even have to floor and if it does exist, take the person to that floor. The str and repr methods are pretty similar except the str method is a "prettier" version of the repr method. It needs to be as such because this is what is printed for the user to see and the repr is for the programmer. They are both representations of the class.
The labs themselves are really helpful because I get to play around with the topics we were introduced to. I always try out the labs before the actual lab starts. I haven't had any issues thus far because the topics are pretty self explanatory and if I do have an issue, just playing around in the labs helps answer my question.
I really like learning by myself because I think I get the most learning experience when I learn from my mistakes so while learning about classes, I would keep making new classes and running them to see what values and inputs I get. In the end, it helped me figure out what I wasn't understanding or missing so I could fix it.
No comments:
Post a Comment