— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet50/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   46   47   48   49   50   51   52   53   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

 rotate(shapeNum, xPt, yPt) {
// if the shape is not an amoeba,
// calculate the center point
// based on a rectangle,
// then rotate
// else
// use the xPt and yPt as
// the rotation point offset
// and then rotate
}
At Brad’s laptop on his lawn 
chair at the Telluride Bluegrass Festival
Without missing a beat, Brad modifi ed the rotate 
method, but only in the Amoeba class. He never 
touched the tested, working, 
compiled code
for the other 
parts of the program. To 
give the Amoeba a rota-
tion point, he added an 
attribute that all Amoebas 
would have. He modi-
fi ed, tested, and delivered 
(wirelessly) the revised 
program during a single 
Bela Fleck set.
Amoeba
int xPoint
int yPoint
rotate() {
// code to rotate an amoeba
// using amoeba’s x and y 
}
playSound() {
// code to play the new 
// .hif file for an amoeba
}


you are here
4
classes 
and 
objects
31
So, Brad the OO guy got the chair, right ?
Not so fast.
Larry found a flaw in Brad’s approach. And, 
since he was sure that if he got the chair he’d also get Lucy 
in accounting, he had to turn this thing around.
LARRY: You’ve got duplicated code! The rotate 
procedure is in all four Shape things.
BRAD: It’s a 
method
, not a procedure. And they’re 
classes

not things.
LARRY: Whatever. It’s a stupid design. You have to 
maintain four different rotate “methods”. How can that 
ever be good?

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   46   47   48   49   50   51   52   53   ...   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