C# 0 The Complete Reference


PART I C h a p t e r   6



Download 4,07 Mb.
Pdf ko'rish
bet182/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   178   179   180   181   182   183   184   185   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   6 :  

I n t r o d u c i n g   C l a s s e s   a n d   O b j e c t s  

121


PART IPART I

// Use the return value from AreaPerPerson().

class BuildingDemo {

  static void Main() {

    Building house = new Building();

    Building office = new Building();

    int areaPP; // area per person

    // Assign values to fields in house.

    house.Occupants = 4;

    house.Area = 2500;

    house.Floors = 2;

    // Assign values to fields in office.

    office.Occupants = 25;

    office.Area = 4200;

    office.Floors = 3;

    // Obtain area per person for house.

    areaPP = house.AreaPerPerson();

    Console.WriteLine("house has:\n  " +

                      house.Floors + " floors\n  " +

                      house.Occupants + " occupants\n  " +

                      house.Area + " total area\n  " +

                      areaPP + " area per person");

    Console.WriteLine();

    // Obtain area per person for office.

    areaPP = office.AreaPerPerson();

    Console.WriteLine("office has:\n  " +

                      office.Floors + " floors\n  " +

                      office.Occupants + " occupants\n  " +

                      office.Area + " total area\n  " +

                      areaPP + " area per person");

  }

}

The output is the same as shown earlier.



In the program, notice that when 


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   178   179   180   181   182   183   184   185   ...   1096




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