GameProgramming – Week 3

This week classes.

You want to build up a program like a brick house a lot of objects that you put together to form a whole. In programming you create classes and then use them by creating objects of them, that way you can have many that are alike. If for example one should create a class that represent a piece in checkers one could then create an object for each piece to represent it. That is one way to use classes and the one we have learned this week.

A class can inherit from an other class, it means that it will get all that is in that class and able to use all that is public or protected. As an example you can have a class that represent animal and then a specific species class(Cat, Dog, Bird, Fish..) that inherit from animal. They belong together and instead of writing all code again that is needed to describe the animal you write function that covers the general description and then have another class that continues on that. So the class cat describes cats in general and then there are subclasses for more specific, like Persian cat or something. This was part of one of the weeks exercises.

Things getting harder and the exercises longer. It doesn’t help that one tends to gets annoying errors, when doing the cards assignments I got memory errors and they are not very clear to exactly what is wrong so instead of just sitting and trying to find out what to do with it I moved on to the next exercise, I eventually went back though and managed to find out what was the problem. It was through the use of a function called srand that as far we knew was something needed if you wanted different random numbers in your program, that was about it, apparently it can not be used twice in the program which I had done.

Did not quite finish this weeks exercises so ain’t going to publish it all yet but when I am done they will be here as usual.

SD022-Exercices_-_Week3

About Isak Ekedahl

2014  Programming