Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# looking for basic object oriented examples

Posted on 2013-10-29
Medium Priority
292 Views
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
Question by:rgb192
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 23

Accepted Solution

Rajkumar Gs earned 2000 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

ID: 39610887
0

LVL 16

Expert Comment

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

ID: 39629613
Human properties attributes

shapes actions draw

Thanks
0

## Featured Post

Question has a verified solution.

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

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â€¦
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
###### Suggested Courses
Course of the Month4 days, 11 hours left to enroll