Solved

looking for basic object oriented examples

Posted on 2013-10-29
4
281 Views
Last Modified: 2013-11-07
Basic example, not looking for very complex

The only basic example I can find is that one house uses a blueprint of many houses.
I am looking for different examples

Real examples of projects you have done

What was a class

what were methods

what were properties
0
Comment
Question by:rgb192
4 Comments
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 500 total points
ID: 39610841
Hi

Class - say 'Human' as a class
            There are variety of human in earth varing in their colour in skin, hair, eye etc, But basically they have red blood, same organs etc. Those common characters can be called as a Class .

Properties - Color, Height , Weight etc are properties

Methods - Say 'Question' as a method. If you ask the human a question (input parameter) , he/she will analyse your input (question) and will respond based on the knowledge (algorithm of that method)

Class is a group of all the common properties and methods

Hope you got some idea
Raj
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 39610887
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 39611530
Back when I was learning OOP (when C++ was the 'new' language), the OOP book gave something like the following as a basic example.

Start with a Class named 'Shape'.  Give it properties of 'CenterX', 'CenterY', and 'Color'.  Add a virtual method 'Draw()'.

Derive from 'Shape' classes like 'Square' and 'Circle'.  Each derived class will have additional properties:
Circle will need a property of 'Radius'.
Square will need a property of 'Length'.    

Write the 'Draw()' method for Circle and Square.

Now, you can create an array of 'Shape' objects.  But the 1st shape can actually be a 'Square' while the 2nd shape can actually be a 'Circle'.  Using Shape[0] and Shape[1], you can update the color or location (CenterX, CenterY) of the object, because these are the common 'Shape' properties that you can update without having to know the details of the derived class (like the radius of the circle or the length of one side of the square).

Because the base class 'Shape' defined the Draw() function, you can call things like Shape[0].Draw() and Shape[1].Draw() without even knowing what type of shape these objects are.  Thru the power of polymorphisim, Shape[0].Draw() will actually call Square::Draw() while Shape[1].Draw() will actually call Circle::Draw().

This example really comes more from C++, so things might be a touch different for C#.  But the concept is still the same in any OOP language.  Even go old Visual Basic has some of these OOP properties... like the fact it could implement the polymorphisim described above (it just didn't support inheritance - so you had to do a bunch of Copy-n-Paste to simulate that).
0
 

Author Closing Comment

by:rgb192
ID: 39629613
Human properties attributes
human actions ask a question

shapes properties radius length
shapes actions draw

Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question