Civil GIS OO Lect1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

app1

myapp
Re-Usability
Problem
Press
Push

object:
P1 P2 P3 Form Textbox Button Form DDList Button property
behavior

width width size items


height Font text width
GTS1 GTS2 GTS3 title Text ... ....
OnOpen() OnSelect() OnClick() OnSelect()
OnClose() .... ...
myapp
S1 S2 S3 Push

myapp
Solution

Push
Object Oriented is based on:

Inh
on

e ri
Encapsulation

ti
ula

ta n
object:

ps

ce
Inheritance property

ca
En
behavior
Polymorphism
Overloading
Overriding
Polymorphism

methods

member
data

A_Value()

Change_A()
class Complex Creating Object:
{ 1) Declare Object
private int Real; 2) Create Object
private int Imag;
public int GetR()
{ return Real;}
public void SetR(int r) Access Modifier: Real = 5 Real = 15
{ Real = r; } private: no one can access private member except Imag = 7 Imag = 18
public int GetI() member of the same class
{ return Imag;}
public void SetI(int i) public: any one can access public member
{ Imag = i; }
public void Print()
{ Console.WriteLine($"Real = {Real}");
Console.WriteLine($"Imag = {Imag}");
}
}

class MyClass
{
public static void Main()
{
Complex cpl1; //Declaration
cpl1 = new Complex(); //Creation
Complex cpl2; //Declaration
cpl2 = new Complex(); //Creation
cpl1 cpl2
cpl1.SetR(5);
cpl1.SetI(7);
cpl2.SetR(15);
cpl2.SetI(18);
Console.WriteLine(cpl1.GetR());
}
}

You might also like