Object Oriented Programming
By Sarfraz Raza
Teacher Assistants:
Aimen Khalid, Maryam, Usman Gill , Abdullah Nezami, Faraz
Teacher Assistants:
Aimen Khalid, Maryam, Usman Gill , Abdullah Nezami, Faraz
Average vs Genuine Programmer
Memory needed for Chess Design
Convention used for Black and White pieces
Improving readability of the code
Two dimensional array for chess Board
Every game is a loop
Initialization
Print Board
Turn Message
Source Piece Select
do while loop
Is Valid Selection
Destination Piece Select
do while loop
Is Valid Destination
Write On Board
Turn Change
Chess Boot Camp Phase 1 - Video Lecture
Is horizontal/ vertical/ diagonal path functions
Is horizontal/ vertical/ diagonal path clear
Legality functions for each of the six pieces of chess
Chess Boot Camp Phase 2 - Video Lecture
Getting input through mouse click
Go to row column function
Highlight
Un-highlight
Check
Self Check
Check Mate
Stale mate
Save to file
Load from file
Undo move
Replay
Castling
Incorporating all functions in game loop
Logical errors
Debugging an example erroneous program (Faulty Calculator I)
Where to apply the debug/ break point?
State of the program
Functions of Ctrl+F5, F5, Shift+F5, F10, F11, Shift+F11
Detailed debugging of Faulty Calculator I
Assignment 1: Debug Faulty Calculator I and II
Logic of subtracting numbers and carry
Right to left vs left to right subtraction
Using the subtraction logic to subtract two dates
Age Calculator
Valid Date function
Valid Current Date function
Calculate Age function
Debugging Age Calculator program
Quiz 1: Two sum problem
Reference to a variable
Pointers
& operator (creating reference, getting address)
* operator (creating pointer, dereferencing)
Name of array is a pointer
Size of pointer
Memory addressing and memory maps
Segments of memory
Stack Segment
Heap Segment
Code Segment
Global Segment
Four types of pointers
Allocating array size at run time
Allocating memory in heap
new keyword
Looking into changing the size of dynamic array
Memory maps
Assignment discussion
Segregation Problem
Electronic Voting
Loading parties from file
Maintaining votes of each party
Printing in the required format
Dynamic Array
Creating 2D Dynamic arrays
Memory Diagram of 2D Dynamic Array
Example problem (Binary Conversion) explained
Integer to Binary Conversion function
Main flow of the program
Implementation in C++
Loading students records without structs
What are structures?
Making structs in C++
User defined data type
Size of struct in bytes
Loading student records from file in array of struct 'Student'
Printing student array
Sorting records on basis of different attributes
Position struct
Snake struct - an array of Positions, size, score, snake symbol
Movement of snake
Game over condition
kbhit
Starting the main flow of the game
Initialization function
Printing snake
Starting implementation in C++
Display snake
The main loop
Change direction function
Move snake function
Food display
Food capture
Snake expand
Valid food
Regenerate food
Polynomial Struct
Load
Get Coefficient
Addition
Subtraction
Evaluate
Derivative
Integral
The Story of OOP
Charles Babbage and Ada Lovelace
The Start Of Programming
The Advent of Programming Languages
Current Era of Programming
Time Class
Public and Private Attributes
Setters and Getters
What is This pointer and How it works
Universal Time
Standard Time
Sets Class
Constructors
Destructor
IsPresent Utility Function
Load
Creating new objects in Switch Statement
Write in File
Intersection
Union
Complement
Disjoint
Equal Sets
Disjoint
Superset
Subset
Proper subset
Constructor
Destructor
Discussion of Chapter 9 from "C++ How To Program" by Deitel and Deitel 9th Edition
Use of #pragma once
Constructor
Default, Parametrized, Copy
Use + benefits of Member Initialization list
Exception Throwing
Try Catch
Quiz - Scenarios in which copy constructor gets called
Static and global variables
Destructors
Order in which constructors and destructors are called
Composition.
A detailed discussion of Composition from Deitel 9th Edition Book.
Static Variables.
How Static variables are not part of any Object?
Applications of static variables.
Static Functions.
How Static variables are not part of any Object?
Why we can't access class members (variables) in Static Function?
Benefits of Static Functions and variables.
Introduction to Friend Functions and Friend Class.
The Basic idea of notepad functionalities.
Discussion about How Windows notepad works?
Demo of Text Editor Project.
Loading recently made documents.
Opening password-protected documents.
Finding and highlighting the substring from the entire document.
Opening multiple documents at the same time.
Implementation of:
InsertCharacterAt_i (___); (function).
Receiving Arrow keys and implementing them on console.
Revision of Friend Classes and Functions.
Quiz on Composition and Friend classes.
Complete Discussion on required classes for the project:
Lines Class
Document Class
Text Editor Class
Explanation of all requirements of Text Editor Project.
Features
Functionalities
Complete Discussion on "Line Class" and all of its required functions from the given header file.
Discussion of Singleton Design Pattern
Creating a single object of class
Private Constructor
Static functions and Pointers
Vector Class (STL)
Introduction
Discussion of functions in detail
Discussion of all Operators in C++
Operators
Overloading unary operators:+,-,!
Overloading arithmetic operators: +, -, *, /, %, *= ,/=
Overloading Logical Operators
Overloading increment and decrement operators : -- , ++
Overloading I/O operators: cin, cout
Syntax and return type of operator overloading function
Implementation ofComplex Number Class using Operator Overloading
Dynamic allocation of arrays
Various Constructors
Overloading operators for:
Addition
Subtraction
Multiplication
Division
Transpose
Equality
Unary and Scalar operations
Rotations - clockwise and anticlockwise
Discussion of Huge Integer Class
Basic Introduction
Constructor (Allocating memory, increasing and decreasing size)
Destructor
Using Operator in huge integers for inputting and displaying the huge integers
Loading Huge Integers
Displaying and storing in reverse order
Friend functions in huge integers
Overloading [] operator to access specific index of a huge integer
Adding two huge integers - QuantityWise
Subtracting two huge integers - QuantityWise
Multiplying two huge integers - Doubling Technique
Discussion of Huge Integer Class
Quantity-wise addition of huge integers
Quantity-wise subtraction of huge integers
Multiplying 2 huge integers - Doubling Technique
Dividing 2 huge integers - Doubling Technique
Quantity-wise Comparisons
Overloading addition and subtraction operators
Overloading multiply and divide operators
Overloading comparison operators
Object Relationships
Discussion of chapter # 16 from learncpp.com in detail.
Introduction to
composition
Aggregation
Association
Differences between composition, aggregation and association
Discussion of multiple examples where each of them should be used
Discussion on Composition, Aggregation and Association was continued
Introduction to Inheritance
Discussion of chapter # 17 from learncpp.com in detail
Derived Classes - order of Constructors and Destructors
Private, Protected, and public inheritance
Discussion of differences between the type of inheritances and which scenarios should employ each of them
Practice for the coding competition "Code Rush" organized under GDSC ITU chapter
Growable array
Vector
Segregate function
Prison Break
The concept of prison break
Prison - a 2d vector
Implementation of Prison Break
Modular approach - Functions
Polymorphism
What is polymorphism?
Discussion of the basics
Discussion of chapter # 18 from learncpp.com in detail
Early and Late Binding
Virtual Functions
Discussion using examples
Pointers and references to base class of derived objects
Virtual functions
Override specifier
Virtual destructor
Early binding
Static binding
Virtual table
Examples
Pure virtual functions
Interface classes
Dynamic Casting
Introduction to shogi
Shogi rules
Using OOP principles to implement chess
Classes for the project
Starting implementation
enum for colors
Implementation
Piece class
Inheritance and polymorphism for implementing pieces classes
Board class
Chess class
Shogi project discussion
Thinking machine
Computer vs Human
Borland Graphics Interface
Draw cell function
Draw board function
Adding mouse click
Creating shapes on console