Well, another week of CSC148 and boy were sub classes a pain. Actually I had learned about sub classes back in high school and how they could use the functions of the class they inherit from but it was slightly different since I learned how to do this in Java. There are a few small differences on how inheritance works but the idea is more or less the same. The sub class has all the same attributes as the class it inherits from and is also able to use any of the functions created for the master class. In addition, these methods can be slightly modified so they perform different thing when working with a specific subclass. For example, in our lab we made a Vehicle class and a subclass Car. The Car sub class could have used the method to get somewhere but it could be modified such that a car uses the fuel efficiency x2 in order to get to where they wanted to go. Overall sub classes are extremely useful since the methods do not need to be recreated for each subclass since they inherit it from the master class and they can have their own methods that the main class cannot access.
Now, moving on to recursion, it's about the same as what we did in high school as well. In high school we traced functions until we had reached the "base case" or in other words, when the recursion should stop and you begin going back up from the recursive method you went down. It's a bit weird now that we have to look at one case and then when we deal with a different case that contains the old one, we use what we got before but looking back at it, it does appear to save a lot of time when we get into much bigger cases since it's broken down into things we've seen already. I actually plan on going through a few more examples of recursion to refresh my memory a bit and apply what we learned in the lecture about looking back on old examples.
Well that's about it for this weeks post... now I'm going to head back to study for my physics term test coming up pretty soon...
No comments:
Post a Comment