Computer Hope

Software => Computer programming => Topic started by: Northenlad60 on September 23, 2013, 02:18:04 PM

Title: Need an OOP example
Post by: Northenlad60 on September 23, 2013, 02:18:04 PM
Hi,

I have been given a task for tomorrow to give an example to show an understanding of the following:

1. Object Assignment in OOP
2. Inheritance and interfaces in OOP

As I have not done any OOP development before, I hoped someone give an explanation in "Laymen's Terms", so I can build on this?

This would be appreciated.

Thanks
Title: Re: Need an OOP example
Post by: Linux711 on September 23, 2013, 10:22:17 PM
I don't know what language you're using, but C# should be close enough to understand even if you aren't using that language. DotNET Pearls is a very good site for OOP C# description and examples.

Inheritance: http://www.dotnetperls.com/inheritance (http://www.dotnetperls.com/inheritance)

Interfaces: http://www.dotnetperls.com/interface (http://www.dotnetperls.com/interface)

Object assignment is very simple:
Code: [Select]
myObjectType objectName = new myObjectType(param1, param2, etc);

public class myObjectType
{
    public myObjectType(int param1, int param2)
    {
     //this method is executed when class is created using line above
    }

    private doStuff()
    {
    //you can only access this from within this class
    }

    public doStuff()
    {
    //you can access outside this class
    }
}

There are a million other things I could go into, but I think that gives you a good basic idea.