You are on page 1of 3

ZOO ‫מחלקה‬

using System;
{
class Zoo
{
private string name;
private Animal[] arry;
private int currectAmountAnimal;

public Zoo(string name)


{
this.name = name;
arry = new Animal[300];
for (int i = 0; i < arry.Length; i++)
arry[i] = null;
currectAmountAnimal = 0;
}
public string GetName()
{
return this.name;
}
public int GetCurrect()
{
return this.currectAmountAnimal;
}
public Animal[] GetArry()
{
return this.arry;
}
public void SetName(string name)
{
this.name=name;
}

public void AddAnimal(Animal animal)


{
arry[currectAmountAnimal] = animal;
currectAmountAnimal++;
}

}
}
ANIMAL ‫מחלקה‬
using System;
{
class Animal
{
private string name;
private string race;
private string id;

public Animal(string name,string race,string id)


{
this.name = name;
this.race = race;
this.id = id;
}

public string GetName()


{
return this.name;
}
public string GetRace()
{
return this.race;
}
public string GetId()
{
return this.id;
}
public void SetName(string name)
{
this.name=name;
}
public void SetRace(string race)
{
this.race=race;
}
public void SetId(string id)
{
this.id=id;
}
public bool IfSameRace(Animal animal)
{
if (animal.GetRace() == this.race)
return true;
return false;
}

}
}
MAIN ‫מחלקה‬
using System;
{
class Program
{
public static bool ifRaceSame(Animal a1,Animal a2)
{
if (a1.GetRace() == a2.GetRace())
return true;
return false;
}
public static void Main(string[] args)
{
Console.WriteLine("enter name and id of two animals IN ORDER");
Animal animal1 = new Animal(Console.ReadLine(), "dog",
Console.ReadLine());
Animal animal2 = new Animal(Console.ReadLine(), "dog",
Console.ReadLine());

Console.WriteLine(animal1.IfSameRace(animal2));
Console.WriteLine(ifRaceSame(animal1, animal2));
}
}
}

You might also like