— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet141/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   137   138   139   140   141   142   143   144   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

get to know the 
Java API 
you are here
4
141
What needs to change?
We have three classes that need to change: the 
DotCom class (which is now called DotCom instead of 
SimpleDotCom), the game class (DotComBust) and the 
game helper class (which we won’t worry about now).
A
DotCom class 
§
Add a name variable 
to hold the name of the DotCom 
(“Pets.com”, “Go2.com”, etc.) so each Dot-
Com can print its name when it’s killed (see 
the output screen on the opposite page).
DotComBust class continued...
§
Put the DotComs on a grid rather than 
just a single row, and do it for all three 
DotComs.
This step is now way more complex than 
before, if we’re going to place the DotComs 
randomly. Since we’re not here to mess 
with the math, we put the algorithm for 
giving the DotComs a location into the 
GameHelper (Ready-bake) class.
§
Check each user guess with all three 
DotComs, instead of just one.
§
Keep playing the game (i.e accepting 
user guesses and checking them with the 
remaining DotComs) until there are no more 
live DotComs.
§
Get out of main. We kept the simple one in 
main just to... keep it simple. But that’s not 
what we want for the real game.
DotComBust
The game class. 
Makes DotComs, 
gets user input, 
plays until all Dot-
Coms are dead
DotCom
The actual 
DotCom objects.

DotComs know their 


name, location, and 
how to check a user 
guess for a match.
3 Classes:
GameHelper
The helper class 
(Ready-Bake).
It knows how to 
accept user com-
mand-line input, 
and make DotCom 
locations.
5 Objects:
DotComBust
DotCom
DotCom
DotCom
GameHelper
use
s f
or p
layer
input
and to 
m
ak

D
otCom lo
ca
t
ions
crea
tes and plays
with

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   137   138   139   140   141   142   143   144   ...   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