OOPS


Object Oriented Programming


Topics :

Pillars of Object Oriented programming

1. Class and Object
        1.1 Types of Classes
        1.2 How to Create Class
        1.3 Parameter using Class and Object
2. Inheritance
        2.1 Types of Classes in inheritance
        2.2 How to use inheritance
3. Class Security
        3.1 Abstract Class
        3.2 Sealed Class
4. Constructor
5. Interface
        5.1 How to create interface
        5.2 How to Access interface inside the class
6. Polymorphism
        6.1 Types of methods
        6.2 Method Overloading
7. Collection
        7.1 ArrayList
        7.2 Stack
        7.3 HashTable
        7.4 SortedList
            - Types of objects


Pillars of Object Oriented Programming- most imp
    class and object
    Inheritance
    Class security
    Constructor
    Interface
    Polymorphism
    Collection Classes

1. Class and Object
    - Class is a collection of member and methods
    - Member : all variable inside the class called member
    - Method : all types of function inside the class called methods
    In class and object cannot count main class
    By default class property is called private
    - Dot is called member access operator or acceesibility operator
    - Class and object BottomUp approach


1.1. Types of classes

1. User class
    - Create before the main class

2. Main class


1.2. How to create class

Class name
{
    member
    method
}


Methods




1.3. Parameter using class and Object



Assig 2
Create a class student
Create a method – input()
Accept following parameter- roll, name, city, branch, clg, total, per
Create a method – display()
Print all information with specific condition
Per>60 && branch=cse && total>150
If condn is true than display all information
Otherwise print readmission


Assignment 3
Convert any three task (function to class and object using named parameter)





2. Inheritance

    - Inheritance is a reusability of class


2.1. Types of classes in inheritance

1. Base class
    - All previous classes is called base class(A,B,C)

2. Derived class
     - After the base class the class is called derived class(BCD)

Class A
Class B
Class C
Class D

    - Inheritance cannot count main body class
    - In inheritance create only last class object

2.2. How to use inheritance

    - With the help of colon operator use inheritance property

Syntax
    DerivedClass : BaseClass

    B:A
    D:C

Note : in C# cannot support multiple inheritance
Ex.
    Class A
    Class B
    Class C
    Class C : A,B;  // its not possible




Assignment 4

Generate the following result
Create a class – College
Create a method – input()
Accept following parameter
Clgid,name,principle,city,state
Create a class – Student
Create a method – datainput()
Parameter is – roll,name,branch,subject,m1,m2,m3,m4,m5
Create a class – Admission
Create a method – display()

Logic
1. Input all parameter by the user
2. Display all information using display() function
3. Calculate the total
4. Check the following condition
Total > 250 – A grade
Total > 150 && total <250 – B grade
Total > 100 && total < 150 – C grade
Otherwise fail

All types of parameters is use to named parameter concept



3. Class Security – most imp

1. Abstract class
2. Sealed Class

3.1. Abstract Class

    - abstract class is to be created using abstract keyword
    - abstract class cannot create a object
    - abstract class only inherit to an other classes




Assignment 5

Create a class – Company(abstract)
Create a method – salary()
Create a member sal(int)
Value of sal = 5000
Create a class – Employee
Create a method – performance()
Check the following condition
Sal>3000 – display A grade employee
Sal > 2000 && Sal <3000 – B grade emp

Otherwise display new joining
Logic
1. Input salary parameters(member) given by the user
2. If user cannot input salary then it receive default value
3. Create only last class object



3.2. Sealed Class

    - Sealed class access with object
    - Sealed class cannot inherit





Assignment 6

Assignment 5 convert into sealed class



4. Constructor

    - constructor is a object initialization process
    - constructor is a method similar to classname

    classA
    {
        Public void A()
    {

    - constructor method cannot use void keyword
    - constructor method automatically access at the time of object creation

- Default Constructor
- Parameterized Constructor
   



Assignment 2

Create a program Constructor with inheritance (imp)



Assignment 3

Convert any one function Asssignment into constructor




5. C# Interface - imp
    - Interface is use to implement multiple inheritance concept
    - C# cannot support multiple inheritance
    - Inside the interface all function is to be declare without specifier(public,private) 

Ex.
    Class A
    Class B
    Class C : A,B //this is multiple inheritance cannot support C#


5.How to Create interface

Syntax :

    Interface name
    {
        Function declaration
    }

Ex.

    Interface Student
    {
        Void display();
    }

    - Function definition is to be created inside the classs

Ex.
    Interface Student
    {
        Void display();
    }

    Class Emp
    {
            Public void display()
            {
            Console.Write(“this is interface”);
            }
    }



5.2 How to access interface inside the class?
    - Using colon : operator

Syntax :
    
    Classname : interface name



Assignment 1
Write a program to generate following result
Create a interface – student
Declare method – input
Accept following parameter (roll, name , city, age , per)

Create interface – result
Declare a method – display()
Logic
1.print all info using display()
2. check the following condition
Per > 60 – Agrase
Per > 50 && per < 60 Bgrade
Per > 40 && per < 50 C grade
Otherwise fail
All input from user




6. Polymorphism
    - polymorphism is a property of class and object
    - in polymorphism multiple classes is use similar function name

Ex.
    Class A
    {
        Show();
    }

    Class B
    {
        Show();
    }

    Class C
    {
        Show();
    }

    - it use to reduce memory allocation concept
    - in polymorphism create two types of objects
            1.base class object
            2.derieved class object with the help of base class

Implementation

    Class A
    {
           Public void display()
            {
                    welcome
             }
     }

    Class B : A    //in polymorphism all class inherit only base class(top class)
    {
          Public void display()
            {
                    nagpur
            }
    }


Object Creation

    A a1 = new A();
    A a2 = new B();
    A a3 = new C();



6.1 Types of method in polymorphism

1. Virtual method – only use base class (top class)
2. override method – create all derived classes





6.2 Function overloading

    - in function overloading function name is similar but activity are different

Ex.
    Void show(int)
    Void show(float)
    Void show(string)

    This concept called function overlading
    In C# function overloading is use to static keyword

Static void show()
Static void show(float)
static void show(string)

    - in function overloading all function is return a specific data value

    static int show()
    static float show()
    static string show()






7. C# Collection - Most imp

    - collection is special type of library use to manage group of data elememt
    - all types of collection methods store inside collection library
    - include collection library with the help of using statement

Ex.
    using system.collection
    Collection Methods
        1. ArrayList
        2. Stack
        3. HashTable
        4. SortedList

7.1.ArrayList




Assignment 6
Input 5 element From the user and store in arraylist
Perform following operation (user choice)
1. Count
2. Sort
3. Display
4. Remove(enter your digit)
5. Remove with index(enter ur index)

Day 11
2 – 12 – 2023

7.2 Stack
    - Arraylist is represent sequential data
    - Stack is represent data in a form of LIFO

Ex.
Stack1 = (a,b,c,d);
LIFO = d,c,b,a

    - Insert element in a stack using push() method
    - Remove element in a stack using pop() method
    - Pop() is use to remove only one element at a time




Class Task 1
Create n no. of stack
Input all element from the user inside the stack
Input choice from the user for removing data element
Result
Enter no. of elemrnt – suppose 5
Enter element 1 – A
Enter element 2 – B
Enter element 3 – C
Enter element 4 – D
Enter element 5 – E
Number of element is to be deleted – 2



7.3 Hashtable
    - Hashtable store dataelement in a particular key
     - Hashtable is use to display data information in random formate
    - Print data randomly

Ex
    101 – Nagpur
    102 – Mumbai
    103 – Pune

   



7.4 Sorted List
    - sorted list is use to input all data in a particular key
    - sorted list is returning all element in a sorted order
    - sorted list is use to create pair object

- Types of Object - imp
    1. Single object
    2. Pair object

Pair Object - imp
    Classname <int,string> objname = new classname<int,string>()

Ex
    A <int,string> a1 = new A<int,string>()
    Pair objects is use to var variable (dynamic varible)



Assignment 1
Combined all program (Arraylist,stack,sortedlist,hashtable) into single program using choice








Comments

Popular posts from this blog

Web Application Development (Dot Net)

C# Programming

SQL(Structure Query Language)