Object Orientated Concepts
Overview The world is objects Defining an object Not a function, it’s a method Lets inherit want we can Objects don’t have ‘mains’ Look at some Java Code
The world is objects (pg 34) Everything is an object. They have values Things can be done to them In small groups, starting with the object of a car, what are some methods about the car?
How does Java know what an object looks like? Class definition public class ExampleApp{ public static void main (Strings[] args){ //some main code } public void ExampleMeth{ //Some other code }
Not a function, it’s a method Methods can be public or private In C, all functions are public They work on the object and sometimes accept inputs
Lets inherit want we can (pg. 31) An object ‘cat’ is a subset of ‘animal’ hence cat inherits the traits of animal A new object ‘mushroom’ might inherit some of the ‘animal’ superclass but would have some very different methods and instance variables
Objects don’t have ‘mains’(pg.38) Objects don’t have a ‘main’ If there is a ‘main’ it should test the current object only
Lets look at some Java code in detail (pg. 39) Take a few minutes to look over the code on page 39.
Things to remember Java and C share some syntax This can be tricky When doing OOP, think of code as interacting objects rather than a program that does different tasks OOP can lead to easier revisions later, but a lot of the worlds code is not OOP