Classes practice
It's been a bit since I did a blog post, but I have still been practicing. The asteroid course I was doing really drained my desire to keep working on it, but I'm happy to say that I finished that off this afternoon.
I learned about classes and inheritance while doing the OOP course, but I feel like there was still some things I have been misunderstanding or could use more practice in. I noticed this while doing the asteroid game. I decided to have ChatGPT help me with a practice session on understanding and using classes and subclasses.
For my practice, I am doing a zoo. I have an animal base class, with three subclasses, Lions, Elephants, and Penguins. I also have a Zookeeper class, that has tasks to fulfill like feeding the animals, cleaning up poop, adding or removing animals from the zoo. It has been a nice refresher on stuff that I thought I might not full understand. I have really enjoyed using AI to help me learn, and I don't think I would have gotten as far as I have without it.
Some of the key principles that I have learned from this practice in particular is the importance of indentation and how it affects how the code runs. If I have an if statement and I don't indent the subsequent lines correctly, it can make the program run in weird ways that I don't want.
I also need to remember that the code doesn't run all in a sheet at once, it runs from top to bottom. So if I have a variable down low on my program, but need it close to the top, it wont run. I need to work on knowing when and where to store key variables or lists at the top of my program for easy access when it runs.
Comments
Post a Comment