Professional Documents
Culture Documents
Polimorzmus
Krizsn Zoltn1
ltalnos Informatikai Tanszk
Miskolci Egyetem
Krizsn Zoltn1
1/42
Polimorzmus
Tartalom
Polimorzmus
ltalnos informcik
Metdus felldenils
Jrm osztly virtulis metdussal
Grakus szerkeszt plda
Absztract metdus, absztrakt osztly
Krizsn Zoltn1
2/42
Polimorzmus
Kts fogalma
Krizsn Zoltn1
3/42
Polimorzmus
A poliformizmus implementcii
Metdusnv tlterhels
Krizsn Zoltn1
4/42
Polimorzmus
5/42
Polimorzmus
Tartalom
Polimorzmus
ltalnos informcik
Metdus felldenils
Jrm osztly virtulis metdussal
Grakus szerkeszt plda
Absztract metdus, absztrakt osztly
Krizsn Zoltn1
6/42
Polimorzmus
Krizsn Zoltn1
7/42
Polimorzmus
Override minst
Krizsn Zoltn1
8/42
Polimorzmus
Krizsn Zoltn1
9/42
Polimorzmus
Virtulis metdus
Krizsn Zoltn1
10/42
Polimorzmus
Krizsn Zoltn1
11/42
Polimorzmus
Krizsn Zoltn1
12/42
Polimorzmus
Krizsn Zoltn1
13/42
Polimorzmus
Metdus kitakars/rejts
Krizsn Zoltn1
14/42
Polimorzmus
Kitakars plda
1
2
3
4
5
6
7
class A{
}
class B : A{
public void Foo () { Console . WriteLine ("B :: Foo () " ); }
}
Krizsn Zoltn1
15/42
Polimorzmus
Kitakars plda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Test {
static void Main ( string [] args ){
A a;
B b;
a = new A () ;
b = new B () ;
a. Foo () ; // output --> "A :: Foo () "
b. Foo () ; // output --> "B :: Foo () "
Krizsn Zoltn1
a = new B () ;
a. Foo () ; // output --> "A :: Foo () "
16/42
Polimorzmus
Krizsn Zoltn1
17/42
Polimorzmus
Tartalom
Polimorzmus
ltalnos informcik
Metdus felldenils
Jrm osztly virtulis metdussal
Grakus szerkeszt plda
Absztract metdus, absztrakt osztly
Krizsn Zoltn1
18/42
Polimorzmus
Krizsn Zoltn1
19/42
Polimorzmus
Magyarzat
Krizsn Zoltn1
20/42
Polimorzmus
Krizsn Zoltn1
21/42
Polimorzmus
Magyarzat
Krizsn Zoltn1
22/42
Polimorzmus
Hasznlat
1
2
3
4
5
6
7
8
9
10
11
12
13
Krizsn Zoltn1
23/42
Polimorzmus
Magyarzat
Krizsn Zoltn1
24/42
Polimorzmus
Tartalom
Polimorzmus
ltalnos informcik
Metdus felldenils
Jrm osztly virtulis metdussal
Grakus szerkeszt plda
Absztract metdus, absztrakt osztly
Krizsn Zoltn1
25/42
Polimorzmus
Krizsn Zoltn1
26/42
Polimorzmus
Tervezsi dntsek
Krizsn Zoltn1
27/42
Polimorzmus
Krizsn Zoltn1
28/42
Polimorzmus
Osztlyterv
Nem teljes
Els vltozat
Finomtsra
fellvizsglatra
szorul.
Krizsn Zoltn1
29/42
Polimorzmus
Kd elemzse
Krizsn Zoltn1
30/42
Polimorzmus
Kd elemzse
Circle osztlyban:
1 void MoveTo ( int
2
Hide () ;
//
3
X = NewX ; //
4
Y = NewY ;
5
Show () ;
//
6 }
Krizsn Zoltn1
31/42
Polimorzmus
Mi trtnik / hvdik?
A klnbsg:
a Point osztly MoveTo metdusban a Point Hide()-ja
hvdik meg
a Circle osztly MoveTo metdusban a Circle Hide()-ja
hvdik meg
Az algoritmus brmilyen alakzatra ugyanaz.
Krds: rklhet-e a MoveTo , vagy kln implementci
szksges minden osztlyra?
Krizsn Zoltn1
32/42
Polimorzmus
Magyarzat
Krizsn Zoltn1
33/42
Polimorzmus
Krizsn Zoltn1
34/42
Polimorzmus
35/42
Polimorzmus
Tartalom
Polimorzmus
ltalnos informcik
Metdus felldenils
Jrm osztly virtulis metdussal
Grakus szerkeszt plda
Absztract metdus, absztrakt osztly
Krizsn Zoltn1
36/42
Polimorzmus
Krizsn Zoltn1
37/42
Polimorzmus
Krizsn Zoltn1
38/42
Polimorzmus
Krizsn Zoltn1
39/42
Polimorzmus
Krizsn Zoltn1
40/42
Polimorzmus
Krizsn Zoltn1
41/42
Polimorzmus
Hibalehetsgek
Krizsn Zoltn1
42/42