Head First Java a brain-Friendly Guide Kathy Sierra and Bert Bates



Download 17,18 Mb.
Pdf ko'rish
bet82/90
Sana22.06.2022
Hajmi17,18 Mb.
#693704
1   ...   78   79   80   81   82   83   84   85   ...   90
Bog'liq
(Head Up) Kathy Sierra Bert Bates - Head First Java, 3rd Edition Early Release-O\'Reilly Media, Inc. (2021)

Integer.parseInt()
to get the int value of a String.
Integer.parseInt()
works only if the String represents
a digit (“0”,”1”,”2”, etc.)
Use 
break
to leave a loop early (i.e. even if the boolean test
condition is still true).
How many hits did you get last month?
Including repeat
visitors?


The game’s main() method
Just as you did with the SimpleStartup class, be thinking about parts of this
code you might want (or need) to improve. The numbered things are for 
stuff we want to point out. They’re explained on the opposite page. Oh, if
you’re wondering why we skipped the test code phase for this class, we
don’t need a test class for the game. It has only one method, so what would


you do in your test code? Make a separate class that would call main() on
this class? We didn’t bother.



random() and getUserInput()
Two things that need a bit more explaining, are on this page. This is just a
quick look to keep you going; more details on the GameHelper class are at
the end of this chapter.



One last class: GameHelper
We made the Startup class.
We made the game class.
All that’s left is the helper class
— the one with the getUserInput() method.
The code to get command-line input is more than we want to explain right
now. It opens up way too many topics best left for later. (Later, as in chapter
14.)
Just copy* the code below and compile it into a class named GameHelper.
Drop all three classes (SimpleStartup, SimpleStartupGame, GameHelper)
into the same directory, and make it your working directory.
Whenever you see the 
logo, you’re seeing code that you
have to type as-is and take on faith. Trust it. You’ll learn how that code
works 
later
.



Download 17,18 Mb.

Do'stlaringiz bilan baham:
1   ...   78   79   80   81   82   83   84   85   ...   90




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