Docsity

OO programing lecture 1, Lecture notes of Computer Applications

Partial preview of the text

Download OO programing lecture 1 and more Lecture notes Computer Applications in PDF only on Docsity!

Advanced Object-Oriented

Programming

Introduction

  • (^) Introduction
  • (^) Pause to Look Backwards and Forwards
  • (^) Course Objectives
  • (^) Course Operation/Expectations
  • (^) Course Plan and Syllabus
  • (^) OO Basic Concepts

Course Objectives

  • (^) To expose students to Object oriented design strategy and

problem solving, objects and classes,

  • (^) To learn various important OO concepts, i.e.
    • (^) member functions,
    • (^) public and private members,
    • (^) dynamic memory management,
    • (^) constructors and destructors,
    • (^) templates,
    • (^) object encapsulation,
    • (^) derived classes,

Course Objectives

  • (^) class hierarchies,
  • (^) inheritance and polymorphism,
  • (^) operator overloading,
  • (^) stream class,
  • (^) practical design through object-oriented programming.
  • (^) To learn the advantages of programming in

an object-oriented language such as C++.

  • (^) To experience programming in the

Large

5

Course Operation/Expectations (continued)

Labs per week ??

  • (^) Approx 6 Assignments and 6 quizzes

2 Exams

  • (^) Mid-term
  • (^) Final

Plagiarism Policy

No Plagiarism will be tolerated.

  • (^) Any attempt of copying code during the lab

and assignment will result in a disciplinary

action and zero marks in that lab/assignment

to the students.

  • (^) The quizzes will be mostly unannounced

and normally last for fifteen minutes. It will

be the instructor’s will to choose the number

of quizzes for evaluations purposes.

10

Grading

Exams:– ~60%

  • (^) Mid Term:- 20%
  • (^) Final Term:- 40%

Assignments and Quizzes:– ~20%

  • (^) Labs and Subjective Evaluation:– ~20% Satisfactory grades in Labs are required to pass course

Recommended Books

  • (^) Object Oriented Programming in C++
  • (^) Fourth Edition,
  • (^) Robert Lafore

Questions?

A sample Code in C++

  • (^) // include header file with the class declaration
  • (^) #include "frac.hpp"
  • (^) // include standard header files
  • (^) #include
  • (^) #include
  • (^) // **** BEGIN namespace CPPBook
  • (^) namespace CPPBook {

A sample Code in C++…

  • (^) /* constructor for numerator and denominator
  • (^) */
  • (^) Fraction::Fraction(int n, int d)
  • (^) : numer(n), denom(d) // initialize numerator and denominator as passed
  • (^) {
  • (^) // 0 as denominator is not allowed
  • (^) if (d == 0) {
  • (^) // exit program with error message
  • (^) std::cerr << "error: denominator is 0" << std::endl;
  • (^) std::exit(EXIT_FAILURE);
  • (^) }
  • (^) }

A sample Code in C++…

  • (^) /* print
  • (^) */
  • (^) void Fraction::print()
  • (^) {
  • (^) std::cout << numer << '/' << denom << std::endl;
  • (^) }
  • (^) } // **** END namespace CPPBook
  • (^) ********************************

An object has unique identity

state

behaviors

State(attributes) consists of a set of data fields (properties)

with their current values.

Behavior(operations) of an object is defined by a set of

methods.

data field 1 method n data field m method 1 (A) A generic object ... ... State (Properties) Behavior radius = 5 findArea() Data field, State Properties Method, Behavior (B) An example of circle object

OO Programming Concepts

  • (^) Classes:
    • (^) People,books,dogs,cats,cars,airplanes,trains,etc.
  • (^) Instance of a class
    • (^) You, your parents, the book you are reading, the car you

drive

Example: Car class

Property names Method Names

model startEngine

year stopEngine

Color accelerate

OO Programming Concepts