«C# dasturlash tili» O’quv qo’llanma


Instruksiyaning ketma-ketmaligi



Download 0,57 Mb.
bet61/76
Sana20.07.2022
Hajmi0,57 Mb.
#828017
1   ...   57   58   59   60   61   62   63   64   ...   76
Bog'liq
C # ma\'lumotnoma

Instruksiyaning ketma-ketmaligi.

  1. YAngi fayl yarating va uni Help classdemo.cs. shaklida nomlang. Chunki programmaning kodiga Qaytmasligi uchun va uni help 3.cs. fayli orQali nusxa olinadi.

Koddan o’zgaruvchan ekzemplyarga yetshish uchun bu o’zgaruvchan aniQlangan sinfni bir Qismi bo’lgan ob’ektni nomi operator nuQta va o’zgaruvchini ismi ko’rsatilishi zarur. Shu o’zgaruvchan aniQlangan sinfni bir Qismi bo’lgan koddan o’zgaruvchan ekzemplyarga yetishish uchun to’g’ridan-to’g’ri o’zgaruvchanni ismini ko’rstish mumkin.
2. Argument – bu metodni chaQirishda unga beriladigan Qiymat.
3. Metoddan boshQaruvni Qaytarish Return operatori yordamida amalga oshirilishi mumkin. Agar metod void tipga ega bo’lsa, metod chaQirib olinganni Qaytarish yopiQ figurali Qavs bilan amalga oshiriladi. BiroQ (ne- void) tipdagi Qiymatni Qaytarish uchun Return operatoridan foydalanish zarur, ya’ni yopiQ figurali Qavsga erishilganda metoddan boshQaruvni Qaytarish mumkin emas.
1. helpon () usulini yaratish.
Public void helpon (char what) (switch (what) ( case ‘1’:
Console.Writeline (“operator”if:g’n”);
Console.Writeline (“if(condition)ststement;”);
Console.Writeline (“else ststement;”);
Break;
Case ‘2’:
Console.Writeline (“operator switch:g’n”);
Console.Writeline (“switch expression)(“);
Console.Writeline (“ case constant:”);
Console.Writeline (“ statement sequence”);
Console.Writeline (“break ;”);
Console.Writeline (“ G’G’ ”);
Console.Writeline (“ (”);
Break;
Case ‘3’:
Console.Writeline (“Sikl for :g’n”);
Console.Writeline (“while(condition;iteration)”);
Console.Writeline (“statement;”);
Break;
Case ‘4’:
Console.Writeline (“sikl while:g’n”);
Console.Writeline (“while (condition) statement;”);
Break;
Case ‘5’:
Console.Writeline (“sikl do-while:g’n”);
Console.Writeline (“do (“);
Console.Writeline (“ (“statement;”);
Console.Writeline (“)while (condition);”);
Break;
Case ‘6’:
Console.Writeline (“operator break:g’n”);
Console.Writeline (“Break; or break label;”);
Break;
Case ‘7’:
Console.Writeline (“operator continue:g’n”);
Console.Writeline (“continue;or continue label;”);
Break;
Case ‘8’:
Console.Writeline (“operator goto:g’n”);
Console.Writeline (“goto label;”);
Break;
Console.Writeline ();
4. showmenu () usulini yaratish ketma-ketligi:
Public void showmenu () (

Console.Writeline (“sintaksisda ma’lumotnoma:”);


Console.Writeline (“ 1.Operator if”);
Console.Writeline (“ 2.Operator switch”);
Console.Writeline (“ 3.Davr for”);
Console.Writeline (“ 4.Davr while”);
Console.Writeline (“ 5. Davr do-while”);
Console.Writeline (“ 6.Operator break”);
Console.Writeline (“ 6.Operator break”);
Console.Writeline (“ 7.Operator continue”);
Console.Writeline (“ 8.Operator gotog’n”);
Console.Writeline (Davr yoki operator tartib nomeriga Qaytish:”);
Console.Writeline (programmada ishni tugallash uchun q ga Qaytish:”);
)

5. Is valid () usulini yaratish:


Public bool isvalid (char ch) ( if (ch ‘1’ I ch> ‘8’  ch Iq ‘q’)return false;
Else return true;
6. Help sinfidagi usulni yarating:
Class Help
Public void helpon (char what) (switch (what)
( case ‘1’:
Console.Writeline (“operator”if:g’n”);
Console.Writeline (“if(condition)statement;”);
Console.Writeline (“else statement;”);
Break;
Case ‘2’:
Console.Writeline (“operator switch:g’n”);
Console.Writeline (“switch expression)(“);
Console.Writeline (“ case constant:”);
Console.Writeline (“ statement sequence”);
Console.Writeline (“break ;”);
Console.Writeline (“ G’G’ ”);
Console.Writeline (“ (”);
Break;
Case ‘3’:
Console.Writeline (“Sikl for :g’n”);
Console.Write (“for(init; condition;iteration)”);
Console.Writeline (“statement;”);
Break;
Case ‘4’:
Console.Writeline (“sikl while:g’n”);
Console.Writeline (“while (condition) statement;”);
Break;
Case ‘5’:
Console.Writeline (“sikl do-while:g’n”);
Console.Writeline (“do (“);
Console.Writeline (“ (“statement;”);
Console.Writeline (“)while (condition);”);
Break;
Case ‘6’:
Console.Writeline (“operator break:g’n”);
Console.Writeline (“Break; or break label;”);
Break;
Case ‘7’: Console.Writeline (“operator continue:g’n”);
Console.Writeline (“continue;or continue label;”);
Break;
Case ‘8’:
Console.Writeline (“operator goto:g’n”);
Console.Writeline (“goto label;”);
Break;
Console.Writeline ();

Public void showmenu () (


Console.Writeline (“sintaksisda ma’lumotnoma:”);
Console.Writeline (“ 1.Operator if”);
Console.Writeline (“ 2.Operator switch”);
Console.Writeline (“ 3.Davr for”);
Console.Writeline (“ 4.Davr while”);
Console.Writeline (“ 5. Davr do-while”);
Console.Writeline (“ 6.Operator break”);
Console.Writeline (“ 6.Operator break”);
Console.Writeline (“ 7.Operator continue”);
Console.Writeline (“ 8.Operator gotog’n”);
Console.Writeline (Davr yoki operator tartib nomeriga Qaytish:”);
Console.Writeline (programmada ishni tugallash uchun q ga Qaytish:”);
)

Public bool isvalid (char ch) ( if (ch ‘1’ I ch> ‘8’  ch Iq ‘q’)return false;


Else return true;
7. Proekt 3-3 dan main usulini yangi help sinfi orQali yozish. Bu asosiy sinfni Main () Help Class Demo .cs. nomi bilan nomlaymiz.
Usul to’liQ shaklda pastda keltirilgan.
Proekt 4-1.
Proekt 3-3 ma’lumotnoma help sinfiga asoslangan.
Using System;
Class help;
Public void helpon (char what)
(switch (what)
( case ‘1’:
Console.Writeline (“operator”if:g’n”);
Console.Writeline (“if(condition)statement;”);
Console.Writeline (“else statement;”);
Break;
Case ‘2’:
Console.Writeline (“operator switch:g’n”);
Console.Writeline (“switch expression)(“);
Console.Writeline (“ case constant:”);
Console.Writeline (“ statement sequence”);
Console.Writeline (“break ;”);
Console.Writeline (“ G’G’ ”);
Console.Writeline (“ (”);
Break;
Case ‘3’:
Console.Writeline (“Sikl for :g’n”);
Console.Write (“for(init; condition;iteration)”);
Console.Writeline (“statement;”);
Break;
Case ‘4’:
Console.Writeline (“sikl while:g’n”);
Console.Writeline (“while (condition) statement;”);
Break;
Case ‘5’:
Console.Writeline (“sikl do-while:g’n”);
Console.Writeline (“do (“);
Console.Writeline (“ (“statement;”);
Console.Writeline (“)while (condition);”);
Break;
Case ‘6’:
Console.Writeline (“operator break:g’n”);
Console.Writeline (“Break; or break label;”);
Break;
Case ‘7’: Console.Writeline (“operator continue:g’n”);
Console.Writeline (“continue;or continue label;”);
Break;
Case ‘8’:
Console.Writeline (“operator goto:g’n”);
Console.Writeline (“goto label;”);
Break;
Console.Writeline ();

Public void showmenu () (


Console.Writeline (“sintaksisda ma’lumotnoma:”);
Console.Writeline (“ 1.Operator if”);
Console.Writeline (“ 2.Operator switch”);
Console.Writeline (“ 3.Davr for”);
Console.Writeline (“ 4.Davr while”);
Console.Writeline (“ 5. Davr do-while”);
Console.Writeline (“ 6.Operator break”);
Console.Writeline (“ 6.Operator break”);
Console.Writeline (“ 7.Operator continue”);
Console.Writeline (“ 8.Operator gotog’n”);
Console.Writeline (Davr yoki operator tartib nomeriga Qaytish:”);
Console.Writeline (programmada ishni tugallash uchun q ga Qaytish:”);
)

Public bool isvalid (char ch) ( if (ch ‘1’ I ch> ‘8’  ch Iq ‘q’)return false;


Else return true;

)


)
Class HelpClassDemo (
Public static void Main ( ) (
Char choice;
Help hlpobj-new Help;
For(;;) (
Do (
Hlpobj. Showmenu ( );
Do (
Choiceq(char) Console.Read ( );
)while (choiceqq ‘g’n’(choiceqq ‘g’r’);
While (lhlpobj.isvalid(choice) );
If (choice qq ‘q’)break;
Console. WriteLine(“g’n”);
Hlpobj.helpon(choice);
)
)
)
Programmani testdan o’tkazilganda funksiya o’zgarmasdan Qoldi. Bu programma prorammist uchun ma’lumotnoma bazasi sistemasi vazifasini bajaradi.

Download 0,57 Mb.

Do'stlaringiz bilan baham:
1   ...   57   58   59   60   61   62   63   64   ...   76




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