Skip to main content

Week 6: Object Oriented Programming

Hey y'all!

Week 6 of class has come to the end and it is time for me to write yet another delightful post. I hope all of you had a wonderful Valentine's Day! I for one went to see a light hearted play about zombies at Hart House. It was fantastic, if you were wondering.

This week is all about object oriented programming!!! Woot! (*searches on Google to find an exact definition of said topic*) ...Ok I'm back! So object oriented programming! It's something we've all seen before when we first learned how to make classes, with an added bonus of making subclasses with inheritance. 

The premise is quite simple; you want to create a general class for whatever you would like to code, and then when you want to make a specific version of it you'll make a subclass. The subclass should logically be able to have whatever cool features you've made for that class (called inheritance). 

Let me give an example: so let's say you would like to create a general class shirts. This general class will create the instance of a shirt, and you would be able to use the methods within it to choose a size and a colour. But then, you'd like to make specific types of shirts that will have special details in them. You want to make a class that does a similar thing for t-shirts, blouses, and tank tops, all with their own special set of details you can add to them, but you don't want to have to copy out all of the information that was stored in the shirt class. Well, the solution is simple! Create subclasses of shirts, and have them inherit the features of the shirts class. All the subclasses that inherit the features of shirts will now have the methods for assigning a size and a colour but without you needed to have the code physically typed into the class. Now any time you want to create a new type of shirt, you can create a subclass of shirts and not have to worry about the basic details and just worry about the important things like if you want frilly sleeves or a bedazzled collar.

This is a pretty big concept and you really need to try it out a few times to get the feel for it. I urge you all to try it out for yourselves!

Have a stupendous week folks!

Lana :) 

Comments

Popular posts from this blog

Week 12: Halting Problem Visualized

Hello readers! I'm sure you're all hard at work trying to finish assignment 3. I just wanted to take a few minutes to share with you a video I found on the halting problem. It may be a tad overdramatic (especially with the music) and corny, but it does explain the problem quite well. Here's part 1 (which can be skipped if you want): And part 2, which is where the real explanation of the halting function starts (skip to 2:33 if you don't like corny dialogue): Hopefully this helps with your endeavors (or at least is a bit entertaining)! Good luck with the assignment! Lana :)

Week 5: Tracing Recursion

Hello readers! How have you guys been recently? I have been bombarded with a myriad of tests, labs, and assignments, as usual, but I'll holding up alright! Today's blurb is on tracing recursion! As you all know, a recursive function is basically any function that is called within itself. You'll need it any time a bigger problem can be solved by solving smaller versions of a same type of problem until you get your answer to the big one. Kind of. At least that's how I see it. Anyhow, tracing recursion is not as bad as it sounds, it takes some bit of practice, of course, but all in all it will eventually click. Tracing recursion was on the test this week went successfully I should think. The quasi-solution I came out with with involved the function we needed to trace giving the maximum length of any lists that were fed into it, including the length of the overall list. If I am correct, then my tracing would have been successful. We shall see in due time! Bu...

Week 10: How to solve a problem

Hello my good friends! This week is the coveted fall reading break, and I hope you all are doing something useful with your time, like me, who is currently writing my SLOG. Now that the course is nearing its end, I would like to take it back to the beginning and try to solve one of those logic puzzles, using the Polya method we learned in class. I am, afterall, an amateur logician now, am I not? So here is the puzzle I have found from the problem solving wiki page. So without further ado, I present to you: Walk Tilings Suppose you have tiles that are 1x2 rectangles, and you have to tile a walk that is 2x3 units long. You've got three choices: 3 vertical tiles, 1 vertical tile followed by two horizontal tiles, or two horizontal tiles followed by one vertical tiles. How many choices do you have in tiling a 2x4 walk? How about a 2xn walk, where n is some natural number? Do you have a procedure that works for any n? Understanding the Problem Ultimately ...