using System;
namespace Mustaqil_talim
{
class Abuturent // biz yaratgan sinf nomi
{
public string name; // bu modifaktor dastur ishlashi davomida biz obyekt olsak unda ko'rib ishlatishimiz kunkin
public string surname { get; set; } // bu modifaktor ham dastur ishlashi davomida unqa qyimatini obyekt oraqliy to'g'ridan to'g'ri ishlatishimiz munkin,
// bu modifaktor da ma'lumotni uzatish va qabul qilish funksiyasini avtomatik o'rnatib ishlatdik
public int age;
private int bal; // bu modifaktorni sinfdan boshqa joyda ishlatib bo'lmaydi bunga qiymat berish uchun get va set funksiyalarini o'zimiz o'rbatishimiz kerak
public int Bal // bu medod bal degan medodning qiymat berish medodi
{
get { return bal; }
set
{
if (0 < value && value < 189)
{
this.bal = value;
}
else
{
Console.WriteLine("Siz belgilangan oraliqdan tashqaridagi balni kiritdiz");
}
}
}
public string yunalish { get; set; }
public string OTM { get; set; }
public void DispLey() // bu metod to'plangan ma'lumotlarni ekranga chiqarish
{
Console.WriteLine($"Familiya va ism: {surname} {name} yoshi {age} imtihondan olgan bal -- >> {bal}");
}
}
class talaba : Abuturent // Abuturent sinifidan vorislik olish
{
// bu sifda Abuturent sinfinig bazsi qismlaridan boylalandim
public string tug_muas;
public string tal_turi;
public void Displey2()
{
Console.WriteLine($"Hurmatli: {surname} {name} sizning o'qishga {tal_turi} bilan qabul qilindiz");
}
}
class Counter // amallarni qayta yuklash
{
public int Value { get; set; }
public static Counter operator +(Counter counter1, Counter counter2)
{
return new Counter { Value = counter1.Value + counter2.Value };
}
public static bool operator >(Counter counter1, Counter counter2)
{
return counter1.Value > counter2.Value;
}
public static bool operator <(Counter counter1, Counter counter2)
{
return counter1.Value < counter2.Value;
}
public static int operator +(Counter counter1, int val)
{
return counter1.Value + val;
}
}
class Program
{
static void Main(string[] args)
{
Abuturent abutr = new Abuturent(); // sinfdan objekt
// ma'lumotlar kiritish
Console.Write("Abiturent Familiyasi -- >> "); abutr.surname = Console.ReadLine();
Console.Write("Abiturent ismi -- >> "); abutr.name = Console.ReadLine();
Console.Write("Abiturent yoshi -- >> "); abutr.age = int.Parse(Console.ReadLine());
Console.Write("Abiturent to'plagan bal -- >> "); int n= int.Parse(Console.ReadLine()); abutr.Bal = n;
Console.Write("Abiturent topshirgan yo'nalish -- >> "); abutr.yunalish = Console.ReadLine();
Console.Write("Abiturent topshirgan Oliy ta'lim muassasa -- >> "); string b = abutr.OTM = Console.ReadLine();
abutr.DispLey();
talaba talab = new talaba();
if (60<=n)
{
Console.WriteLine($"Siz {b} ta'lim muassasasiga talabalikka qabul qilindiz quyidagi ma'lumotlarni to'ldiring -- >> ");
Console.Write("Talaba Familiyasi -- >> "); talab.surname = Console.ReadLine();
Console.Write("talaba ismi -- >> "); talab.name = Console.ReadLine();
Console.Write("talaba yoshi -- >> "); talab.age = int.Parse(Console.ReadLine());
Console.Write("Tugatilgan ta'lim muassasa -- >> "); talab.tug_muas = Console.ReadLine();
if (85 < n) { talab.tal_turi = "Grad"; }
else
{
if (60 < n) { talab.tal_turi = "To'lov kantrakt"; }
}
}
else
{
talab.tal_turi = "Siz talabalikka tavsiyz etilmadiz uzur qayta imtihon topshirish uchun yaxshilab tayyorlaning";
}
talab.Displey2();
Counter counter1 = new Counter { Value = 23 };
Counter counter2 = new Counter { Value = 45 };
bool result = counter1 > counter2;
Console.WriteLine(result); // false
Counter counter3 = counter1 + counter2;
Console.WriteLine(counter3.Value); // 23 + 45 = 68
Counter counter4 = new Counter { Value = 23 };
int result1 = counter4 + 27; // 50
Console.WriteLine(result1);
}
}
}
Do'stlaringiz bilan baham: |