Solved

looking for basic object oriented examples

Posted on 2013-10-29
4
278 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now