Topshiriqlar Biror nomlar fazosi hosil qiling


public abstract void Kirit


Download 38.5 Kb.
bet2/4
Sana17.06.2023
Hajmi38.5 Kb.
#1545988
1   2   3   4
Bog'liq
komili 2

public abstract void Kirit();
public abstract void Chiqar();
}
class Talaba:Odam
{
public Talaba()
{
Kirit();Chiqar();
}
public override void Kirit()
{
Console.Write("Ismingizni kiriting: ");
FIO=Console.ReadLine();
Console.Write("Manzilingizni kiriting: ");
Manzil=Console.ReadLine();
Console.Write("Yoshingizni kiring: ");
Yosh=Convert.ToInt32(Console.ReadLine());
Console.Write("Vazningizni kiriting (kg): ");
Vazn=Convert.ToInt32(Console.ReadLine());
Console.Write("Bo'yingizni kiriting (sm): ");
Boy=Convert.ToInt32(Console.ReadLine());
Console.Write("Telefoningizni kiring: ");
Telefoni=Convert.ToInt32(Console.ReadLine());
}
public override void Chiqar()
{
Console.Clear();
Console.WriteLine("FIO:\t\t{0}\nManzil:\t\t{1}\nYoshingiz:\t\t{2}\nVazningiz:\t\t{3}kg\nBo'yingiz:\t\t{4}sm\nTelefoni:\t\t{5}\n",FIO,Manzil,Yosh,Vazn,Boy,Telefoni);

}
}
struct Hayvonlar


{
public string Nomi,Turi,Oziqlanishi;
public int Yoshi,Vazni,Uzunligi;
public void Kirit()
{
Console.Clear();
Console.Write("Hayvon nomini kiriting: ");
Nomi=Console.ReadLine();
Console.Write("Hayvon turini kiriting: ");
Turi=(Console.ReadLine());
Console.Write("Oziqlanish shaklini kiriting: ");
Oziqlanishi=(Console.ReadLine());
Console.Write("Yoshini kiring: ");
Yoshi=Convert.ToInt32(Console.ReadLine());
Console.Write("Vaznini kiring (kg): ");
Vazni=Convert.ToInt32(Console.ReadLine());
Console.Write("Uzunligini kiriting kiring (sm): ");
Uzunligi=Convert.ToInt32(Console.ReadLine());
}
public void Chiqar()
{
Console.Clear();
Console.WriteLine("Hayvon nomi:\t{0}\nHayvon turi:\t{1}\nOziqlanishi:\t{2}",Nomi,Turi,Oziqlanishi);
Console.WriteLine("Yoshi:\t\t{0}\nVazni:\t\t{1}kg\nUzunligi:\t\t{2}sm",Yoshi,Vazni,Uzunligi);
}
}
}
namespace komili
{
class Program
{
public static void Main(string[] args)
{ Console.ReadKey(true);
}
}
}
4. Program sinfining Main metodi yordamida hosil qiling sinflar bilan bog’lanishlarni amalga oshiring .
using System;
namespace Jonzotlar
{
abstract class Odam

{
public string FIO,Manzil;


public int Yosh,Vazn,Boy,Telefoni;
public abstract void Kirit();
public abstract void Chiqar();
}
class Talaba:Odam
{
public Talaba()
{
Kirit();Chiqar();
}
public override void Kirit()
{
Console.Write("Ismingizni kiriting: ");
FIO=Console.ReadLine();
Console.Write("Manzilingizni kiriting: ");
Manzil=Console.ReadLine();
Console.Write("Yoshingizni kiring: ");
Yosh=Convert.ToInt32(Console.ReadLine());
Console.Write("Vazningizni kiriting (kg): ");
Vazn=Convert.ToInt32(Console.ReadLine());
Console.Write("Bo'yingizni kiriting (sm): ");
Boy=Convert.ToInt32(Console.ReadLine());
Console.Write("Telefoningizni kiring: ");
Telefoni=Convert.ToInt32(Console.ReadLine());
}
public override void Chiqar()
{
Console.Clear();
Console.WriteLine("FIO:\t\t{0}\nManzil:\t\t{1}\nYoshingiz:\t\t{2}\nVazningiz:\t\t{3}kg\nBo'yingiz:\t\t{4}sm\nTelefoni:\t\t{5}\n",FIO,Manzil,Yosh,Vazn,Boy,Telefoni);
}
}
struct Hayvonlar
{
public string Nomi,Turi,Oziqlanishi;
public int Yoshi,Vazni,Uzunligi;
public void Kirit()
{
Console.Clear();
Console.Write("Hayvon nomini kiriting: ");
Nomi=Console.ReadLine();
Console.Write("Hayvon turini kiriting: ");
Turi=(Console.ReadLine());
Console.Write("Oziqlanish shaklini kiriting: ");
Oziqlanishi=(Console.ReadLine());

Console.Write("Yoshini kiring: ");


Yoshi=Convert.ToInt32(Console.ReadLine());
Console.Write("Vaznini kiring (kg): ");
Vazni=Convert.ToInt32(Console.ReadLine());
Console.Write("Uzunligini kiriting kiring (sm): ");
Uzunligi=Convert.ToInt32(Console.ReadLine());
}
public void Chiqar()
{
Console.Clear();
Console.WriteLine("Hayvon nomi:\t{0}\nHayvon turi:\t{1}\nOziqlanishi:\t{2}",Nomi,Turi,Oziqlanishi);
Console.WriteLine("Yoshi:\t\t{0}\nVazni:\t\t{1}kg\nUzunligi:\t\t{2}sm",Yoshi,Vazni,Uzunligi);
}
}
}
namespace komili
{
class Program
{
public static void Main(string[] args)
{
Jonzotlar.Talaba talaba=new Jonzotlar.Talaba();
Console.ReadKey();
Jonzotlar.Hayvonlar hayvonlar=new Jonzotlar.Hayvonlar();
hayvonlar.Kirit(); hayvonlar.Chiqar();
Console.ReadKey(true);
}
}
}
5. Qism sinflar hosil qiling.
using System;
namespace Jonzotlar
{
abstract class Odam
{
public string FIO,Manzil;
public int Yosh,Vazn,Boy,Telefoni;
public abstract void Kirit();
public abstract void Chiqar();
}
class Talaba:Odam
{
public Talaba()
{
Kirit();Chiqar();
}


public override void Kirit()
{
Console.Write("Ismingizni kiriting: ");
FIO=Console.ReadLine();
Console.Write("Manzilingizni kiriting: ");
Manzil=Console.ReadLine();
Console.Write("Yoshingizni kiring: ");
Yosh=Convert.ToInt32(Console.ReadLine());
Console.Write("Vazningizni kiriting (kg): ");
Vazn=Convert.ToInt32(Console.ReadLine());
Console.Write("Bo'yingizni kiriting (sm): ");
Boy=Convert.ToInt32(Console.ReadLine());
Console.Write("Telefoningizni kiring: ");
Telefoni=Convert.ToInt32(Console.ReadLine());
}
public override void Chiqar()
{
Console.Clear();
Console.WriteLine("FIO:\t\t{0}\nManzil:\t\t{1}\nYoshingiz:\t\t{2}\nVazningiz:\t\t{3}kg\nBo'yingiz:\t\t{4}sm\nTelefoni:\t\t{5}\n",FIO,Manzil,Yosh,Vazn,Boy,Telefoni);
}
}
struct Hayvonlar
{
public string Nomi,Turi,Oziqlanishi;
public int Yoshi,Vazni,Uzunligi;
public void Kirit()
{
Console.Clear();
Console.Write("Hayvon nomini kiriting: ");
Nomi=Console.ReadLine();
Console.Write("Hayvon turini kiriting: ");
Turi=(Console.ReadLine());
Console.Write("Oziqlanish shaklini kiriting: ");
Oziqlanishi=(Console.ReadLine());
Console.Write("Yoshini kiring: ");
Yoshi=Convert.ToInt32(Console.ReadLine());
Console.Write("Vaznini kiring (kg): ");
Vazni=Convert.ToInt32(Console.ReadLine());
Console.Write("Uzunligini kiriting kiring (sm): ");
Uzunligi=Convert.ToInt32(Console.ReadLine());
}
public void Chiqar()
{
Console.Clear();
Console.WriteLine("Hayvon nomi:\t{0}\nHayvon turi:\t{1}\nOziqlanishi:\t{2}",Nomi,Turi,Oziqlanishi);
Console.WriteLine("Yoshi:\t\t{0}\nVazni:\t\t{1}kg\nUzunligi:\t\t{2}sm",Yoshi,Vazni,Uzunligi);

}
}
}


namespace komili
{
class Program
{
public static void Main(string[] args)
{
Jonzotlar.Talaba talaba=new Jonzotlar.Talaba();
Console.ReadKey();
Jonzotlar.Hayvonlar hayvonlar=new Jonzotlar.Hayvonlar();
hayvonlar.Kirit(); hayvonlar.Chiqar();
Console.ReadKey(true);
}
}
}
6. Qism sinflardagi maydon, metod va xossalar bilan ishlang.
using System;
namespace Jonzotlar
{
class Odam
{
public string FIO,Manzil;
public int Yosh,Vazn,Boy,Telefoni;

}
public partial class Talaba


{
public string FIO,Manzil;
public int Yosh,Vazn,Boy,Telefoni;
public Talaba()
{
Kirit();
}
public void Kirit()
{
Console.Write("Ismingizni kiriting: ");
FIO=Console.ReadLine();
Console.Write("Manzilingizni kiriting: ");
Manzil=Console.ReadLine();
Console.Write("Yoshingizni kiring: ");
Yosh=Convert.ToInt32(Console.ReadLine());
Console.Write("Vazningizni kiriting (kg): ");
Vazn=Convert.ToInt32(Console.ReadLine());
Console.Write("Bo'yingizni kiriting (sm): ");


Boy=Convert.ToInt32(Console.ReadLine());
Console.Write("Telefoningizni kiring: ");
Telefoni=Convert.ToInt32(Console.ReadLine());
}
public void Chiqar()
{
Console.Clear();
Console.WriteLine("FIO:\t\t{0}\nManzil:\t\t{1}\nYoshingiz:\t\t{2}\nVazningiz:\t\t{3}kg\nBo'yingiz:\t\t{4}sm\nTelefoni:\t\t{5}\n",FIO,Manzil,Yosh,Vazn,Boy,Telefoni);
}
}
public partial class Talaba
{
public string OTM{set;get;}


int kurs,talabalik_yili;
public int Kurs
{
set
{
if(0<value && value<4)
kurs=value;
else Console.WriteLine("Xato kiritdingiz!!!");
}
get{return kurs;}
}
public int Talabalik_yili
{
set 
{
if(0<value && value<4)
{talabalik_yili=value;}
else Console.WriteLine("Xato kiritdingiz!!!");
}
get{return talabalik_yili;}
}
public void Kirit1()
{
Console.Write("O'qish joyini kiriting:");
OTM=Console.ReadLine();
Console.Write("Kursingizni kiriting:");
Kurs=int.Parse(Console.ReadLine());
}
public void Chiqar1()
{

Console.WriteLine("O'qish joyi:\t{0}\nO'qish yili:{1}yil\nHozirda:\t{2} kurs",OTM,talabalik_yili,Kurs);


}

}


struct Hayvonlar
{
public string Nomi,Turi,Oziqlanishi;
public int Yoshi,Vazni,Uzunligi;
public void Kirit()
{
Console.Clear();
Console.Write("Hayvon nomini kiriting: ");
Nomi=Console.ReadLine();
Console.Write("Hayvon turini kiriting: ");
Turi=(Console.ReadLine());

Console.Write("Oziqlanish shaklini kiriting: ");


Oziqlanishi=(Console.ReadLine());
Console.Write("Yoshini kiring: ");
Yoshi=Convert.ToInt32(Console.ReadLine());

Console.Write("Vaznini kiring (kg): ");


Vazni=Convert.ToInt32(Console.ReadLine());
Console.Write("Uzunligini kiriting kiring (sm): ");
Uzunligi=Convert.ToInt32(Console.ReadLine());
}
public void Chiqar()
{
Console.Clear();
Console.WriteLine("Hayvon nomi:\t{0}\nHayvon turi:\t{1}\nOziqlanishi:\t{2}",Nomi,Turi,Oziqlanishi);
Console.WriteLine("Yoshi:\t\t{0}\nVazni:\t\t{1}kg\nUzunligi:\t\t{2}sm",Yoshi,Vazni,Uzunligi);
}
}
}
namespace komili
{
class Program
{

Download 38.5 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling