









































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










































































SUBMISSION
SUBMISSION
❒ SUMMATIVE FEEDBACK: ❒ RESUBMISSION
Figure 1 : Introduction
Figure 2 : OOP
Figure 3 : Class and Object
- Object (Object)
- Class (Class)
Figure 4 : Example
//Base Class public class Father { public void FatherMethod() { Console.WriteLine("this property belong to Father"); } } //Derived class public class Child : Father { public void ChildMethod() { Console.WriteLine("this property belong to Child"); } } class Inheritance { //Entry point static void Main(string[] args) { Father fObj = new Father (); fObj.FatherMethod(); //Here Child object can access both class methods Child cObj = new Child (); cObj.FatherMethod(); cObj.ChildMethod(); } }
public abstract class Employee { public virtual void LeaderName() { } } public class hrDepart : Employee { public override void LeaderName() { Console.WriteLine("Mr. jone"); } } public class itDepart : Employee { public override void LeaderName() { Console.WriteLine("Mr. Tom"); } } public class financeDepart : Employee { public override void LeaderName() { Console.WriteLine("Mr. Linus"); } } class PolymorphismDemo {
public override void displayData() { Console.WriteLine("Abstract class method"); } } class abstractClass { static void Main(string[] args) { // class instance new test ().displayData(); } }
- SEALED CLASSES
- EXAMPLE:
sealed class SealedClass { void myfunv(); } public class test : SealedClass //wrong. will give compilation error { }
- INTERFACE
- EXAMPLE: // interface public interface xyz { void methodA(); void methodB(); } // interface method implementation class test : xyz { public void methodA() { Console.WriteLine("methodA"); } public void methodB() { Console.WriteLine("methodB"); } } class interfaceDemo { static void Main(string[] args) { test obj = new test (); obj.methodA(); obj.methodB(); } }
public interface xyz { void methodA(); void methodB(); }
static void Main(string[] args) { Student oStudent = new Student(); oStudent.Name = "James"; oStudent.GPAScore = 80; Parent oParent = new Parent(); oParent.Name = "Daddy Cool"; oStudent.NotifyToParent += new NotifyGpaDelegate(oParent.NotifyMe); oStudent.RecordGPAScore(); } } public delegate void NotifyGpaDelegate(int GPAScore); class Student { public event NotifyGpaDelegate NotifyToParent; public String Name { get; set; } public int GPAScore { get; set; } public void RecordGPAScore() { if (NotifyToParent != null) NotifyToParent(GPAScore); } } class Parent { public String Name { get; set; } public void NotifyMe(int pGPAScore) {
Console.WriteLine(String.Format("{0} notified about the GPA {1}", Name, pGPAScore.ToString())); } }
4. RELATIOSHIP BEETWEN POP, OOP, EDP