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



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

import java.io.*;
public class GameHelper {
public String getUserInput(String prompt) {
String inputLine = null;
System.out.print(prompt + “ “);
try {
BufferedReader is = new BufferedReader(
new InputStreamReader(System.in));


inputLine = is.readLine();
if (inputLine.length() == 0 ) return null;
} catch (IOException e) {
System.out.println(“IOException: “ + e);
}
return inputLine;
}
}
*We know how much you enjoy typing, but for those rare moments when
you’d rather do something else, we’ve made the Ready-bake Code available
on 
wickedlysmart.com
.
Let’s play
Here’s what happens when we run it and enter the numbers 1,2,3,4,5,6.
Lookin’ good.
A complete game interaction
(your mileage may vary)


What’s this? A bug ?
Gasp!
Here’s what happens when we enter 1,1,1.
A different game interaction (yikes)



 SHARPEN YOUR PENCIL
It’s a cliff-hanger!
Will we 
find
the bug?
Will we 
fix
the bug?
Stay tuned for the next chapter, where we answer these questions and
more...
And in the meantime, see if you can come up with ideas for what went
wrong and how to fix it.
More about for loops
We’ve covered all the game code for 
this
chapter (but we’ll pick it up again
to finish the deluxe version of the game in the next chapter). We didn’t want
to interrupt your work with some of the details and background info, so we
put it back here. We’ll start with the details of for loops, and if you’re a
C++ programmer, you can just skim these last few pages...

Download 17,18 Mb.

Do'stlaringiz bilan baham:
1   ...   79   80   81   82   83   84   85   86   ...   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