— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet66/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   62   63   64   65   66   67   68   69   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

Tonight’s attendees:
Class Method Object Instance variable


46
 
chapter 2
A
B
Code Magnets:
File Edit Window Help Dance
% java DrumKitTestDrive
bang bang ba-bang
ding ding da-ding
class DrumKit {
boolean topHat = true;
boolean snare = true;
void playTopHat() {
System.out.println(“ding ding da-ding”);
}
void playSnare() {
System.out.println(“bang bang ba-bang”);
}
}
class DrumKitTestDrive {
public static void main(String [] args) {
DrumKit d = new DrumKit();
d.playSnare();
d.snare = false;
d.playTopHat();
if (d.snare == true) {
d.playSnare();
}
}
}
class TapeDeck {
boolean canRecord = false;
void playTape() {
System.out.println(“tape playing”);
}
void recordTape() {
System.out.println(“tape recording”);
}
}
class TapeDeckTestDrive {
public static void main(String [] args) {
TapeDeck t = new TapeDeck( );
t.canRecord = true;
t.playTape();
if (t.canRecord == true) {
t.recordTape();
}
}
We’ve got the template, now we have
}
to make an object !
class DVDPlayer {
boolean canRecord = false;
void recordDVD() {
System.out.println(“DVD recording”);
}
void playDVD ( ) {
System.out.println(“DVD playing”);
}
}
class DVDPlayerTestDrive {
public static void main(String [] args) {
DVDPlayer d = new DVDPlayer();
d.canRecord = true;
d.playDVD();
if (d.canRecord == true) {
d.recordDVD();
}
}
The line: d.playDVD( ); wouldn’t
}
compile without a method !

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   62   63   64   65   66   67   68   69   ...   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