914-guruh talabasi O`ktamov Orziqul
17. Name va Age xususiyatlariga ega Animal nomli sinf yarating. Xususiyatlar uchun olish va o'rnatish bloklarini amalga oshiring. Hayvon chiqaradigan tovushni konsolga yozadigan MakeSound() usulini qo'shing.
using System;
class Animal{
public string Name;
public int age;
public virtual void MakeSound()
{
Console.WriteLine("Woof");
}
public void print(){
Console.WriteLine(Name);
Console.WriteLine(age);
}
}
class program {
static void Main(){
Animal I = new Animal();
I.Name = "It";
I.age = 2;
I.MakeSound();
I.print();
}
}
Do'stlaringiz bilan baham: |