I have an Animal class with X properties and Tiger class with B properties. The Tiger class inherits from the Animal. When I create an instance of the tiger class, how I put the arguments of the Animal class?
Thanks :)
class Program
{
static void Main(string[] args)
{
Animal dogA = new Tiger()
dogA.Run();
Console.ReadLine();
}
}
class Animal
{
public int Age { get; set; }
public string Color { get; set; }
public float Speed { get; set; }
public Animal(int age, string color, float speed)
{
Age = age;
Color = color;
Speed = speed;
}
public virtual void Run()
{
float runSpeed = (-1 * Speed) + 100;
Console.WriteLine("I'm running at {0} kph", Speed);
}
}
class Tiger : Animal
{
public int Legs { get; set; }
public Tiger(int legs)
{
Legs = legs;
}
public override void Run()
{
double runSpeed = (Legs * Speed) / 2.5;
Console.WriteLine("I'm running at {0} kph", Speed);
}
}