using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace animale
{
class animal
{
protected string nume;
protected string hrana;
public animal()
{
}
public animal(string n)
{
nume = n;
}
virtual public void mananca()
{
hrana = "hrana";
}
public void citire()
{
Console.Write("Nume=");
nume = Console.ReadLine();
}
public void afis()
{
Console.WriteLine(nume + " mananca " + hrana);
}
}
class pisica : animal
{
public pisica()
{
}
public pisica(string n)
{
nume = n;
}
public override void mananca()
{
hrana = "Wiskas";
}
}
class caine : animal
{
public caine()
{
}
public caine(string n)
{
nume = n;
}
public override void mananca()
{
hrana = "Chappy";
}
}
class Program
{
static void Main(string[] args)
{
animal[] a = new animal[3];
a[0]=new animal("Animalu");
a[1] = new pisica("Fify");
a[2] = new caine("Juni");
a[0].mananca();
a[1].mananca();
a[2].mananca();
a[0].afis();
a[1].afis();
a[2].afis();
Console.ReadKey();
}
}
}
|