Task 2 – OOD

Task 2


In OOD a class is basically just a general idea for something, it contains all the details and characteristics of something, for example if the class is a person then it will have details of their age, height, weight, gender etc.  Classes are given their own names by the user, these names always need to be relevant to the classes’ subject and not clash with a name already used by the program, for example a car class should be name something like “Car1” not anything like “String”. In each class there are a set of objects, all of the objects in the class will have something in common with each other. However each object inside the class will have its own separate function, for example in the “Human” class it will have height, weight and age, and all off these are different objects.



Usually the user assigns properties to the classes that they make. Properties are basically just the characteristics of an object, like what it does or how it acts. For example in a gun class this might include the fire rate and the reload time. The properties of the instance will be similar to that of the class, when the program is ran an instance is created of everything. Class inheritance is where a subclass inherits properties or behaviours from the main class. This means that it takes certain parts of the main class, like if the main class was a person then the subclass was their child then the child might have taken the “height” from the main class. The image below shows the properties of the players experience, in a class. Also it shows the inheritance of his “new” player is inheriting from “myPlayer”



A method is just an action that has been turned into a function and this allows interaction within the game world. Encapsulation is where you keep all of your code for something in one place, like a class. You use encapsulation because it keeps all of your code neat and tidy, making it easier to find and edit if there is a problem with that part of the code. For example in a shooting and driving game then one class will have all of the shooting part in it, but it won’t have anything to do with the driving because this will complicate it. A method header is the title of the behaviour of an object, it gives the user the information on  how to use the object. The method body is linked in with the method header, the body is how the object is used. Attribute visibility is to do with the public and private methods, when the method is public it can be accessed by anything, however when it is private it can not. This image shows the method.



Polymorphism is just part of inheritance which allows your classes to have more than one type. For example it means that if you have a human class then the main class might be called “CarClass” then below that might be “SuperCar” and because of polymorphism there will be a child of the “SuperCar” class, something like “Ferrari”. This is used because then the “SuperCar” class can be used to call something on every child class. A message header is just the main default part of the message which does not change, and the message body is the part that’s changes depending on circumstances, for example. “Your character” is the message head and “has received 10 xp” is the message body. These make up the whole message which makes sense. Method overloading is creating multiple methods that have the same name but have different implementations. When an overloaded function is called it will call something that has  a context to the call, allowing one function to perform the task depending on the context. Communication between objects is how objects can interact with each other so see where the other object its planning on going so they do not collide, they can work together. Overriding messaging is a sub or child class can implement something that is already provided in one of the parent classes.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s