programming laboratory-1 · i.e. - after base features are extended by samsung brand. now samsung...

22
Programming Laboratory-1 Avani M. Sakhapara Assistant Professor IT Dept,KJSCE

Upload: others

Post on 05-Jun-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Programming Laboratory-1

Avani M. Sakhapara

Assistant Professor

IT Dept,KJSCE

Page 2: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Examination Scheme

Subject

Code

Subject Name Examination Scheme

Theory Marks Term

Work

Practical Oral Total

Continuous Assessment (CA) End

Sem.

Exam Test 1 Test

2

IA

UITL304

Programming

Laboratory – I

-- -- -- --

50 25 25 100

Subject

Code

Subject Name Teaching Scheme Credits Assigned

Theory Practical Tutorial Theory Practical Tutorial Total

UITL304

Programming

Laboratory – I

-- 02 02 -- 02 01 03

Page 3: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Course Outcomes

After the completion of this course you will be able to

1. Apply object-oriented design methodology using C++ programming.

2. Demonstrate use of dynamic memory allocation and pointers.

3. Demonstrate use of functions and file handling methods

4. Demonstrate use of generic classes and exception handling.

Page 4: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Need of Object Oriented Programming Easy to develop solutions for real world problems

Class <CAR>

Page 5: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Classes and Objects

Object <7_series_BMW>

Object <Ford_Mustang>

Object <VW_Beetle>

Page 6: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Messages to Objects

Object <7_series_BMW>

“Start the engine of the BMW”

Start_Engine

Page 7: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Methods of a Class

Class <CAR>

Start_Engine

Page 8: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Classes

• A Class is a plan which describes the object.

• We call it as a blue print of how the object should be represented.

• It defines what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object.

• A class is to an object, as a blueprint is to a building

Page 9: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Objects

• Any real world entity which can have some characteristics or which can perform some work is called as Object.

• An Object is an instance of the class

• Each Object consist of

1. Attributes/Characterisitics/Properties

2. Behaviour/Function/method

Page 10: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Example

• A Mobile can be a class which has some attributes like Profile Type, IMEI Number, Processor, and some more.) & operations like Dial, Receive & SendMessage.

Page 11: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Basic Concepts of OOP

• The four essential features of OOP are

1. Abstraction

2. Encapsulation

3. Inheritance

4. Polymorphism

Page 12: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Abstraction

• Abstraction says, only show relevant details and rest all hide it.

• This is most important pillar in OOPS as it is providing us the technique to hide irrelevant details from User.

• If we consider an example of any mobile like Nokia, Samsung, IPhone. Some features of mobiles

• Dialing a number call some method internally which concatenate the numbers and displays it on screen but what is it doing we don’t know.

• Clicking on green button actual send signals to calling person’s mobile but we are unaware of how it is doing.

• This is called abstraction where creating method which is taking some parameter & returning some result after some logic execution without understating what is written within the method

Page 13: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Encapsulation

• Encapsulation is defined as the process of enclosing one or more details from outside world through access right.

• It says how much access should be given to particular details. • Both Abstraction & Encapsulation works hand in hand because

Abstraction says what details to be made visible & Encapsulation provides the level of access right to that visible details. i.e. – It implements the desired level of abstraction.

Example Talking about Bluetooth which we usually have it in our mobile. When we switch on the Bluetooth I am able to connect another mobile but not able to access the other mobile features like dialing a number, accessing inbox etc. This is because, Bluetooth feature is given some level of abstraction.

Page 14: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Abstraction and Encapsulation

Page 15: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Polymorphism

• Polymorphism means one name many forms

Example

• Let’s say Samsung mobile have the 5MP camera available i.e. – it is having a functionality of CameraClick(). Now same mobile is having Panorama mode available in camera, so functionality would be same but with mode.

Page 16: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Inheritance

• Ability to extend the functionality from base entity in new entity belonging to same group. This will help us to reuse the functionality which is defined before.

• Example:

Basic Mobile functionality is to Send Message, dial & receive call. So the brands of mobile is using this basic functionality by extending the mobile class functionality and adding their own new features to their respective brand.

Page 17: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Inheritance

• There are mainly 4 types of inheritance:

• Single level inheritance

• Multi-level inheritance

• Hierarchical inheritance

• Hybrid inheritance

• Multiple inheritance

Page 18: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Single level inheritance

Page 19: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Multilevel inheritance In Multilevel inheritance, there is more than one single level of derivation. i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like Android OS, v4.4.2 (kitkat). From generalization, getting into more specification.

Page 20: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Hierarchal inheritance

In this type of inheritance, multiple derived class would be extended from base class, it’s similar to single level inheritance but this time along with Samsung, Nokia is also taking part in inheritance.

Page 21: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Hybrid inheritance Single, Multilevel, & hierarchal inheritance all together construct a hybrid inheritance.

Page 22: Programming Laboratory-1 · i.e. - After base features are extended by Samsung brand. Now Samsung brand has manufactured its new model with new added features or advanced OS like

Procedure Oriented v/s Object Oriented Programming Procedural programming:

• Low-level, closer to hardware

• More intuitive, less abstract

• More ‘action’ oriented

• Focus on ‘action’, ‘procedure’, ‘method’

• Uses top-down approach

Object-oriented programming: • High-level

• More abstract

• Focus on ‘what to do’ not on ‘how to do’