— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet190/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   186   187   188   189   190   191   192   193   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

198
 
chapter 8
Animal
Feline
roam()
Canine
size
picture
food
prey
Lion
size
picture
food
prey
Tiger
size
picture
food
prey
Cat
size
picture
food
prey
Wolf
size
picture
food
prey
Dog
size
picture
food
prey
Hippo
makeNoise()
eat()
roam()
makeNoise()
eat()
makeNoise()
eat()
makeNoise()
eat()
makeNoise()
eat()
makeNoise()
eat()
picture
food
hunger
boundaries
location
makeNoise()
eat()
sleep()
roam()
designing with 
inheritance 
Did we forget about something 
when we designed this?
The class structure isn’t too bad. We’ve designed 
it so that duplicate code is kept to a minimum, 
and we’ve overridden the methods that we think 
should have subclass-specifi c implementations. 
We’ve made it nice and fl exible from a 
polymorphic perspective, because we can design 
Animal-using programs with Animal arguments 
(and array declarations), so that any Animal 
subtype—including those we never imagined at the 
time we wrote our code
—can be passed in and used 
at runtime. We’ve put the common protocol for 
all Animals (the four methods that we want the 
world to know all Animals have) in the Animal 
superclass, and we’re ready to start making new 
Lions and Tigers and Hippos. 



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   186   187   188   189   190   191   192   193   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish