You are on page 1of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Rationale

Object-oriented concepts forms the base of all modern programming languages. Understanding the basic concepts of object-orientation helps the developer to use such languages more effectively. The C++ language was developed to implement the concepts of object-oriented programming. The module is applicable to anyone planning to enter the world of object-oriented programming, using the C++ language. This module is essential as it provides a strong foundation in object-oriented programming approaches and application of the same.

Ver. 1.0

Session 1

Slide 1 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Objectives

In this session, you will learn to:


Define objects and classes Identify messages and methods of a class Explain features of the object-oriented approach State the activities involved in object-oriented analysis and design Create classes in C++

Ver. 1.0

Session 1

Slide 2 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

The Foundation of Object-Orientation

Object-orientation is a type of methodology used for building software applications. Object-oriented methodology in software development revolves around a single concept called the object. Software is developed by breaking the application concept into component objects that interact with each other when the whole application is put together.

Ver. 1.0

Session 1

Slide 3 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Objects An object literally means a material thing that is capable of being presented to the senses. An object has the following characteristics:
It has a state. It may display a behavior. It has a unique identity.

Ver. 1.0

Session 1

Slide 4 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Just a minute

Identify the possible states of the following objects: 1. Cell phone 2. Stereo

Answer: 1. States of a Cell phone: Off, Ringing, Vibrating, and Calling 2. States of a Stereo: Playing, Pausing, Rewinding, and Forwarding

Ver. 1.0

Session 1

Slide 5 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Classes

A class can be defined as a declaration, a template, or a blueprint that can be used to create objects. Example:

Birds

Peacock

Sparrow

Kingfisher

Ver. 1.0

Session 1

Slide 6 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Messages and Methods

Messages:
Are transmitted by one object to another Are transmitted as requests for an action to be taken Are accompanied by additional information needed to carry out the request

Methods:
Are a set of actions taken by the receiver object in response to the request

Ver. 1.0

Session 1

Slide 7 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Just a minute

Dr. James and Mr. Hyde went to the railway station to book two tickets in the Flying express. Identify the following:
1. The possible receiver of the message in this situation 2. The possible method that the receiver can use

Answer:
1. The receiver of the message here will be the clerk sitting behind the counter. 2. The clerk will check if two tickets are available on the train in the desired class on the desired date. If they are, the clerk will enter the details (either he would put down the details of name, age, date, and seat, in a register or feed it in the computer) and confirm the reservation of the tickets, and collect the fare.
Ver. 1.0

Session 1

Slide 8 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Features of the Object-Oriented Approach

Realistic Modeling
The object-oriented approach helps you in applying the concepts of object-orientation easily in the real world.

Binding Attributes and Behavior Together


An object is a collection of attributes and behaviors. This feature of binding data and properties together in object-oriented approach is known as encapsulation.

Reusability
Using existing classes or objects from other applications, saves a large portion of time and energy spent in recreating the classes from scratch.

Ver. 1.0

Session 1

Slide 9 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Just a minute

State whether the following situations demonstrate reusability:


1. Recycling paper 2. Pump reusability (same pump is used in a well and in a fuel station)

Answer:
1. Does not represent reusability because the paper is destroyed before new paper is made. Hence, the old paper loses its identity and cannot be considered the same as the new paper. Consumption is not reusability. 2. Represents reusability because a pump can be used for suction of water as well as petrol. Here, it is not a single physical pump used in both cases, but both the objects are of the same class Pump.

Ver. 1.0

Session 1

Slide 10 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Features of the Object-Oriented Approach (Contd.)

Resilience to Change
Means that the parts of the system can be redefined without any major change in other parts Is also known as extensibility

Existence as Different Forms


Means that objects can respond differently to the same message. The response is based on the information provided with the message

Ver. 1.0

Session 1

Slide 11 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

The Analysis Phase

Is also known as Object-Oriented Analysis (OOA) Requires users and developers to get together and arrive at a common understanding of the system Requires the developer to concentrate on obtaining as much information as possible about the problem domain

Ver. 1.0

Session 1

Slide 12 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

The Design Phase

Is also known as the Object-Oriented Design (OOD) phase Generates the blueprint of the system that has to be implemented Requires the designer to identify the objects in the system and their interrelationship

Ver. 1.0

Session 1

Slide 13 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

The Implementation Phase

This is also known as the Object-Oriented Programming (OOP) phase. Some applications built using OOP techniques are:
Computer-Aided Design (CAD) Computer-Aided Manufacturing (CAM) Object-Oriented Databases

Ver. 1.0

Session 1

Slide 14 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Just a minute

As a member of a team that is developing software for DialCom Telecommunications, Inc., you have been assigned the task of creating a software module that accepts and displays customer details such as name, age, and phone number. Identify the class that you will create and the methods of the class.

Answer:
As per the problem statement, the class required is:
Customer

As per the problem statement, the class should have the following methods:
Method to accept customer details Method to display customer details on the screen

Ver. 1.0

Session 1

Slide 15 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Creating Classes in C++

In the early 1980s, Bjarne Stroustrup developed the C++ language. C++ was originally known as 'C with classes.

Ver. 1.0

Session 1

Slide 16 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Classes in C++

Example:
class Car { public: void honk() { cout<<"BEEP BEEP!"; } };

Ver. 1.0

Session 1

Slide 17 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Demonstration 1: Creating Classes

As a member of a team that is developing toys for JoyToys, Inc., you have been assigned the task of creating a bike module that accepts and displays bike details. Declare the Bike class and the member functions. The member function that accepts bike details should display the message Accepting Bike Details. Similarly, the member function to display bike details on the screen should display the message Displaying Bike Details.

Ver. 1.0

Session 1

Slide 18 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Practice: Exercise 1

Analyze the process of making a call by using a pay phone. Identify the objects involved and the behavior of these objects. Also, identify the messages passed between the objects for interacting with each other.

Ver. 1.0

Session 1

Slide 19 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Practice: Exercise 2

As a member of a team that is developing an automated ranking system of players in Video Game Parlors, you have been assigned the task of creating a module that accepts the details of the player after a game is over. Declare a class Player, which consists of three member functions, acceptPlayerDetail(), comparePlayerDetil(), and printPlayerRank(). Each of these functions should print the appropriate message on the screen.

Ver. 1.0

Session 1

Slide 20 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Practice: LearnCreatePlay

Create a class Player for the Tic Tac Toe game. The Player class contains functionality for checking the winner when the player makes a move. In addition, the Player class accepts player details at the beginning of the game.

Ver. 1.0

Session 1

Slide 21 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Summary

In this session, you learned that:


According to the object-oriented approach, systems consist of component objects that interact with each other. An object is an entity that may have a physical boundary. In addition, it should have state, behavior, and identity. A class consists of a set of objects that share a common structure and behavior. If an object desires an action from another object, it sends a message to that object. The object that receives the message is called the receiver; and the set of actions taken by the receiver constitutes the method. The features of the object-oriented approach are realistic modeling, binding attributes and behavior together, reusability, resilience to change, and existence as different forms.

Ver. 1.0

Session 1

Slide 22 of 23

Installing Windows XP Professional Using Attended Installation Introduction to Object-Oriented Approach

Summary (Contd.)

A model of the system is built in the stages of analysis and design. The purpose of the model is to help developers understand the reality that they are trying to imitate. Bjarne Stroustrup developed the C++ language in the early 1980s. In C++, a class is created by using the keyword class. It is identified by a name called the class name. Member functions of a class are declared inside the class body. The function definition contains the function code. The cout object is an instance of the class ostream. The class ostream is associated with the standard output device (the monitor). The symbol '<<' is used to direct a value to the standard output device.
Ver. 1.0

Session 1

Slide 23 of 23

You might also like