Solved

looking for basic object oriented examples

Posted on 2013-10-29
4
284 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
[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
  • Learn & ask questions
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Title # Comments Views Activity
Need help with a query 14 54
Building an object from several other objects 4 39
Disable the weekends on datepicker control 6 52
Java import explained 4 49
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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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.

751 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