14.02.2017 Views

. Стиллмен, Дж. Грин - Изучаем C#, 2-е издание

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

инт<strong>е</strong>рф<strong>е</strong>йсы и абстрактны<strong>е</strong> классы<br />

инт<strong>е</strong>рф<strong>е</strong>йсы U насл<strong>е</strong>довани<strong>е</strong><br />

Когда один класс насл<strong>е</strong>ду<strong>е</strong>т от другого, он получа<strong>е</strong>т вс<strong>е</strong> <strong>е</strong>го м<strong>е</strong>тоды<br />

и свойства. Насл<strong>е</strong>довани<strong>е</strong> инт<strong>е</strong>рф <strong>е</strong>йсов происходит <strong>е</strong>щ<strong>е</strong><br />

прощ<strong>е</strong>. Так как в инт<strong>е</strong>рф<strong>е</strong>йсах отсутствуют т<strong>е</strong>ла м<strong>е</strong>тодов, вам<br />

уж<strong>е</strong> н<strong>е</strong> прид<strong>е</strong>тся заботиться о вызов<strong>е</strong> конструкторов и м<strong>е</strong>тодов<br />

базового класса. Насл<strong>е</strong>дующи<strong>е</strong> инт<strong>е</strong>рф<strong>е</strong>йсы просто накапливают<br />

в с<strong>е</strong>б<strong>е</strong> м<strong>е</strong>тоды и свойства своих родит<strong>е</strong>л<strong>е</strong>й.<br />

i n t e r f a c e IW o r k e r<br />

{<br />

s t r i n g J o b { g e t ; }<br />

i n t S h i f t s L e f t { g e t ;<br />

v o i d D o T h i s J o b ( s t r i n g<br />

}<br />

j o b , i n t s h i f t s )<br />

Om созданного ^<br />

НЛММ инт<strong>е</strong>рф<strong>е</strong>й<br />

ca M orker м о­<br />

г у т насл<strong>е</strong>довать<br />

вс<strong>е</strong> остальны<strong>е</strong><br />

инт<strong>е</strong>рф<strong>е</strong>йсы.<br />

Н а д и а г р а м м <strong>е</strong> к л а с с о в<br />

н а с л <strong>е</strong> д о в а н и <strong>е</strong> и н т <strong>е</strong> р ­<br />

ф <strong>е</strong> й с о в о б о з н а ч а <strong>е</strong> т с я<br />

п у н к т и р н о й л и н и <strong>е</strong> й .<br />

i<br />

(interface)<br />

IW orker<br />

Job<br />

ShiftsLeft<br />

DoThisJobO<br />

Worl

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!