Object technology views problem solving from the perspective of objects. You start with analysis to identify the objects. Then you do design to create a master plan that allows an agent to coordinate the action of the objects.
The components in problem solving are called objects. They are the building blocks and tools that interact to produce the final outcome.
Once objects are specified, problem solving must identify an agent who organizes the action among the objects to accomplish the task. Example: a driver.
We view an object in terms of its attributes that describe what it is, and its actions that describe what it can do.
| Attribute | Type | Descripton | Example |
| Make | String | Name of manufacturer | Toyota |
| Model | String | Name of model | Corolla |
| Year | Integer | Year of manufacture | 1984 |
| Colour | String | Colour of paint | Econolodge orange |
| Top speed | Integer | Top speed in km/h | 130 |
Start the engine
Select a gear
Steer
Apply brakes
An object type is a template that describes the attributes and operations available to any object.
In C++, object types are implemented as classes. An object is an instance of a class (or a "class variable"). Object attributes are variables inside a class.
An algorithm is a sequence of instructions that leads to a solution of a problem in a finite amount of time.
In C++, algorithms are implemented as functions. Object actions are functions inside a class.
#include <iostream.h>
class HelloWorld // object type
{
private:
const char * itsMessage; // attribute
public:
HelloWorld( ) // constructor function
{
itsMessage = "Hello, Cruel World!";
cout << itsMessage << endl;
}
}; // <- must have semi-colon
int
main( )
{
HelloWorld myHello; // object called "myHello"
return 0;
}
Download this program
Hockey team class interface (header file)
Hockey team class implementation (source file)
Hockey team test program