�ԸդԴẺ������� (abstract) 㹡���͡Ẻ interface
�ǤԴ㹡���͡Ẻ interface ����ö���͡���� 2 �Ƿҧ��� abstract interface (interface ��ԧ�������) ��� concrete Interface (interface ��ԧ�ٻ����) ��к��¤��駷�� abstract interface �ѡ���ջ���ª��㹡����ҹ�ҡ���� conrete interface ���ͧ�ҡ��ʹ� 㹡�� reuse ����繢�ʹբͧ Object oriented ����
Concrete interface
��ٻẺ�ͧ Concrete interface ��÷ӧҹ�����ҧ��ǹ interface ��� implement ��ᵡ��ҧ�ҡ abstract interface �蹨ҡ������ҧ�ͧ taxi class 㹡���Թ�ҧ�ʹ���ͧ�������� �������è��繨е�ͧ�͡�ҧ����ҧ�����´�褹�Ѻö�������仵����鹷ҧ���١��ͧ �� �ç�����¡ ��������ǫ��� ��������Ǣ����¡�Ѵ� ���
��ʹբͧ����͡Ẻ�Ẻ concrete interface
�������ª��㹤����١��ͧ�ء��鹵�ͧ��ô��Թ�ҹ�������ͧ������ͧ�ҡ����ö�Ǻ�����鹷ҧ��÷ӧҹ������������ö��˹���鹷ҧ��餹�Ѻ�硫��Ѻ�����鹷ҧ�����ҵ�ͧ����� �¤��Ѻ���������ö�Ѻ���� ��ѧ��鹷ҧ��� ���ͷ����������������Թ�ҡ ��鹵�����зҧ��
������¢ͧ����͡Ẻ�Ẻ concrete interface
����դس���ѵԢͧ��� reuse ���ͧ�ҡ����Т�鹵����Ըա��㹡�ô��Թ�ҹ�� ᵡ��ҧ�ѹ� ���������� �������÷�������ʶҹ�����ᵡ��ҧ�ѹ����ͨ���ѧ ʹ���Թ���ǡѹ����������鹷ҧ���ᵡ��ҧ�ѹ �������ö���� reuse �ͧ interface ���ǡѹ��
��ʹբͧ����͡Ẻ��ٻẺ abstract interface
�������ª��㹴�ҹ��� reuse ���ͧ�ҡ��ǹ�ͧ interface ������ö�ӡ�Ѻ���������� ¡������ҧ taxi class �蹼������÷������˹����ҧ��þ�Թ��� ���� �������÷������˹�һ�������ѹ ���� �������÷���������ҹ�� ����͵�ͧ��è���ѧʹ���Թ�����ǡѹ ������ö�� interface ���ǡѹ���� ����駡Ѻ���Ѻö�硫����� ���ͧ����ʹ���Թ� ��������Ҩ�����������͵��˹�㴡�����ö��ѧʹ���Թ�� ⴹ��鹷ҧ���ᵡ��ҧ
������¢ͧ����͡Ẻ��ٻẺ abstract interface
abstract interface ��鹨��������ö�Ǻ����ء��鹵��ô��Թ�ҹ ���� user ��§�Դ��͡Ѻ��ǹ interface ��ҹ�� �� ���ͧ����ʹ���Թ� ���鹵��ô��Թ�ҹ����user �����������Ҥ��Ѻ�оҼ���������ѧ��� �ҧ������� ���ͨ����������������鹵�����зҧ �·�������������Һ��鹷ҧ ��������º��º�Ѻ�ӧҹ��ԧ�ͧ�к���� user ���������ö�Ǻ�����÷ӧҹ����Т�鹵�� user �з�Һ��§��Ҥ�����ͧ���㹡�ô��Թ�ҹ��������ó� ������Һ��鹵���Ѻ��������ͧ��Ѿ�ҡ��Թ�������繨ҡ��÷ӧҹ�ͧ��ǹ implement
���ҧ��ǹ interface �����·���ش
㹡����������͡Ẻ ������ҧ��ǹ interface ����� user �����·���ش ��ҷ�� user ��������ҹ�� ���������ѡ������ԧ���� �������ǹ interface �١�ӡѴ �з���� user ����дǡ㹡����ҹ����觼ŵ�ͻ���Է���Ҿ��÷ӧҹ�ͧ�к� ��������ѧ����� user �դ������繷���ͧ�������ǹ interface ���ǹ����� ����˹�ҷ���͡Ẻ�к�������ö�����������ǹ���������к���������ѧ ��������ͷӡ�����������������ҧ��ǹ interface ����ҡ � 㹵�á���觼����µ���к��ҡ���� �к���������ʶ����Ҿ ���ͧ�ҡ user ������з�����ҹ interface ������äǺ��������ҹ�ͧ�к������ҡ , user �Ҩ���� interface ���ҧ�Դ�Ը� ���㹡������к�������ѧ�ͧ��� �Ѳ���к������ҡ�ҡ
������������ͧ�к��Ѻ�����駡�âͧ user
㹡���͡Ẻ��оѲ���к��е�ͧ�ִ�������ͧ�ͧ user ���Ӥѭ ������͡Ẻ��������ŷ����������ҹ�� ���ͧ�ҡ user �繼����ҹ�к� �ѧ��鹨֧��ͧ�͡Ẻ���������ͧ������ҧ���ԧ�ͧ user ��駹���ͧ��������� �����������㹡����ҹ����
��˹� User �ͧ�к�
user ��ͼ������ͧ�͡����ҹ�к� ���� class �� ���¡�ѧ���ҧ�ͧ taxi class ��觼������èзӡ����ͧ�͡����ҹ�к� ��� ��ͧ����餹�Ѻ����觷��ʹ���Թ (���������� message ��ѧ taxi object �Ԩ�ó����� taxi object �� user) ��Ф��Ѻ��зӡ����ͧ�͡����ҹ�к��蹡ѹ �����ͧ�͡�è����Թ ��Ҽ�������������觷��ʹ���Թ���������Թ ���Ѻ�礧����� (taxi object ���ͧ�� message��ѧ���ⴹ���������ͧ���Թ) �ѧ��鹵�����ҧ����� ����������Ф��Ѻö�硫��з�˹�ҷ���� user ����ͧ���� ��觷ӡ���� message ��ѧ taxi object
��ǹ public interface
㹡�����ҧ��ǹ interface ��� ���ӡ���͡Ẻ��äԴ�����������ʶҹТͧ user ���Ǩз�Һ��§��� ������¡��ҹ object ��������ҧ�Ô ��� uesr ����÷�Һ��� �object ���ҧ�������ҧ�Ô ����繡�èӡѴ�ͺ ࢵ����������ǹ�����繵�� user ��� user ��Һ��ҹ�� ¡������ҧ�硫���ҾԨ�óҷ��cabbie class�����ҧ��ǹ interface
|
Cabbie |
|
+haiTaxi : void +EnterTaxi : void +GreetCabbie : void +Specifydestination : void +payCabbie : void +TipCabbie : void +LeaveTexi : void |
���������ǹ�ͧ interface �ͧ cabbie class �ء method ���繡�á�з������ҧ cabbie class ��� costomer class ��зء � interface �ͧ cabbie ����ǹ��� user ��èз�Һ���ͷ��еԴ��͡Ѻ cabbie class ��кҧ��ǹ��� costomer class ����÷�Һ�ҡ cabbie class ���¡��� Implement ����ö���º��º��������ѧ���
|
Interface |
Implement |
|
���¡�硫�� |
�Ըա�èʹö��º����ص�ҷ |
|
������硫�� |
��䡡���Դ��е� |
|
�ѡ��¤��Ѻ |
��Ҿ����������Ͷ١�ѡ��� |
|
�͡�ش���»��·ҧ |
��鹷ҧ�����ѧ���·ҧ |
|
�����Թ |
��ù��Թ��� |
|
���Ի |
��ù��Թ��� |
|
�͡�ҡ�硫�� |
��䡡���Դ��е� |
��ǹ Implement
��ѧ�ҡ��������ҧ��ǹ interface ���� ����繷��е�ͧ��Һ�֧��ǹ implement ������������� interface ���ͧ�ҡ��ǹ implement �����ǹ���͡�֧�Ըջ�Ժѵԧҹ�������觵������ͧ�ͧ͢ object ��� ��� user �������繢��������ǹ implement ��� ���С�����¡�� object �ͧ user �����¡��ҹ��ҹ��ǹ interface ��ҹ�� �����������§�Ѻ�鴷���������� interface �������ǹ�ͧ implement ���ҧ���ԧ
����ª�������Ѻ�ҡ����¡��ǹ interface ��� implement �͡�ҡ�ѹ ��������͡Ẻ��оѲ���к�����ö��� ����¹�ŧ ���������ǹ implement �����������з���� user �͡�ҡ��� user ���ѧ����ö��ҹ object �����������ͧ�������ǡѺ��ǹ�ͧ��÷ӧҹ���Ѻ�����㹴���
Coppyright2004 By Webmaster All Right Reserved Comments