интерфейсы IComparable и IClonable;
во всех классах реализовать стандартные интерфейсы IComparable и IClonable; создать массив объектов, вторая половина которого должна быть заполнена клонами первой половины; осуществить сортировку массива объектов;
namespace Study
{
internal class Program
{
public static void Main(string[] args)
{
Wolf wolf = new Wolf(45, 3, 55, "Haski", "Forest");
wolf.Print();
Console.WriteLine(" ");
Fox fox = new Fox(30, 2, 75, "Fox", "Forest");
fox.Print2();
Console.ReadLine();
}
}
public abstract class Animal
{
public virtual double Weight { get; set; }
public virtual int Age { get; set; }
public virtual decimal Cost { get; set; }
public Animal(double weight, int age, decimal cost)
{
Weight = weight;
Age = age;
Cost = cost;
}
public virtual void Print()
{
Console.WriteLine("Weight: " + Weight);
Console.WriteLine("Age: " + Age);
Console.WriteLine("Cost in day: " + Cost);
}
public virtual void Print2()
{
Console.WriteLine("Weight: " + Weight);
Console.WriteLine("Age: " + Age);
Console.WriteLine("Cost in day: " + Cost);
}
}
public class Fox : Animal
{
public string Breed { get; set; }
public string Location { get; set; }
public override void Print2()
{
Console.WriteLine("Weight: " + Weight);
Console.WriteLine("Age: " + Age);
Console.WriteLine("Cost in day: " + Cost);
Console.WriteLine("Breed: " + Breed);
Console.WriteLine("Location: " + Location);
}
public Fox(double weight, int age, decimal cost, string breed, string location) : base(weight, age, cost)
{
Breed = breed;
Location = location;
}
}
public class Wolf : Animal
{
public string Breed { get; set; }
public string Location { get; set; }
public override void Print()
{
Console.WriteLine("Weight: " + Weight);
Console.WriteLine("Age: " + Age);
Console.WriteLine("Cost in day: " + Cost);
Console.WriteLine("Breed: " + Breed);
Console.WriteLine("Location: " + Location);
}
public Wolf(double weight, int age, decimal cost, string breed, string location) : base(weight, age, cost)
{
Breed = breed;
Location = location;
}
}
}
}