— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet111/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   107   108   109   110   111   112   113   114   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

Assuming that all but the tiniest programs 
need more than one class (if you’re following 
good OO principles and not having one class 
do many different jobs), where do you start?
brain
power
A


100
 
chapter 5
SimpleDotCom
int [] locationCells
int numOfHits
String checkYourself(String guess)
void setLocationCells(int[] loc)
You’ll get the idea of how prepcode (our version of pseudocode) works as you 
read through this example. It’s sort of half-way between real Java code and a plain 
English description of the class. Most prepcode includes three parts: instance 
variable declarations, method declarations, method logic. The most important 
part of prepcode is the method logic, because it defi nes 
what has to happen, 
which we later translate into 
how, when we actually write the method code.
The prepcode stage
The prepcode stage
 prep code test code
real code
 prep code
DECLARE 
an 
int array
to hold the location cells. Call it 
locationCells.
DECLARE 
an 
int 
to hold the number of hits. Call it 
numOfHits
and 
SET 
it to 0.
DECLARE 

checkYourself()
method that takes a 
String 
for the user’s guess (“1”, “3”, etc.), 
checks it, and returns a result representing a “hit”, “miss”, or “kill”.
DECLARE 

setLocationCells()
setter method that takes an 
int array 
(which has the three cell 
locations as 
ints 
(2,3,4, etc.).
METHOD

String checkYourself(String userGuess)

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   107   108   109   110   111   112   113   114   ...   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