01 Iec t1s1 Oops Session 01
01 Iec t1s1 Oops Session 01
01 Iec t1s1 Oops Session 01
Rationale
Class
Car
Objects
Solution:
1. States of a cell phone: Off, Ring, Vibrate, and Call
2. States of a stereo: Play, Pause, Rewind, and Forward
Dr. James and Mr. Hyde went to the railway station to book
tickets for 3rd December. At the railway station, they requested
the clerk at the ticket counter to book two tickets for the Flying
Express in the first class. Identify the following:
1. The possible receiver of the message in this situation.
2. The possible method that the receiver can use.
Solution:
1. The receiver of the message in this case will be the clerk at
the ticket counter.
2. The clerk will check if two tickets are available on the
requested train in the desired class and for the desired date. If
the tickets are available, the clerk will enter the details (name,
age, departure date, and seat), confirm the reservation, and
collect the required fare.
Ver. 1.0 Session 1 Slide 9 of 45
Object-Oriented Programming Using C#
Characteristics of the Object-Oriented Approach
Realistic modeling
Reusability
Resilience to change
Existence as different forms
Solution:
1. It does not represent reusability because the unusable paper
is destroyed before paper is recycled for use. The unusable
paper loses its identity and cannot be considered the same as
recycled paper.
2. It represents reusability because a pump can be used for
suction of water as well as petrol. It is not necessary to use
the same pump in both the cases. Two separate machines
can be used because both belong to the ‘Pump’ class.
Solution:
As per the problem statement, the class required is:
Customer
The class should have the methods to:
Accept customer details
Display customer details
System.Console.WriteLine("He
llo, World! \n");
}
}
Problem Statement:
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 its 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”.
Let us now understand the various data types with the help
of examples.
int Num;
Num
Num=5; 5
Memory allocated
string Str=“Hello”;
Address Str
H E L L O
0 1 2 3 4
Age
2Strank
Family_Size
Gender
{
Console.WriteLine("Enter the Engine Model");
Engine = Console.ReadLine();
Console.WriteLine("Enter the number of Wheels");
NoOfWheels = Convert.ToInt32(Console.ReadLine());
}
public void DisplayDetails()
{
Console.WriteLine("The Engine Model is:{0}",
Engine);
Console.WriteLine("The number of wheels are:{0}",
NoOfWheels);
}
}
Problem Statement:
David is the member of a team that is developing the
Automatic Ranking software for a tennis tournament. You have
been assigned the task of creating a program. The program
should accept the following details of a tennis player and
display it:
Name, containing a maximum of 25 characters
Rank as an integer
Winning average as a decimal value
Help David to create the program.