If you look at the code below. What would you say is wrong with the Puppy constructor? Is there any obvious between the classes the class Dog and the inherited Puppy?
Puppy class:
class Puppy : Dog
{
// Properties
public int AgeInMonths { get; set; }
override public int Age { get; set; } = 0;
// Constructors
public Puppy(string _name, int _ageInMonths, string _favFood, string _breed, bool _isHungry, List<Toy> _toyList) : base(_name, _ageInMonths, _favFood, _breed, _isHungry, _toyList)
{
Name = _name;
AgeInMonths = _ageInMonths;
FavFood = _favFood;
Breed = _breed;
IsHungry = _isHungry;
Toys = _toyList;
}
public Puppy()
{
Name = "Puppy";
AgeInMonths = 7;
FavFood = "Whiskas";
Breed = "Skogskatt";
IsHungry = false;
Toys =
new List<Toy> {
new Cattree {Size = "Large"},
new Ball {Color = "Yellow"},
};
}
}
}
C#:
class Dog : Animal
{
// Constructors
public Dog () {
Name = "Doggy";
Age = 4;
FavFood = "Frolic";
Breed = "Rotweiler";
IsHungry = false;
new List<Toy> {
new Cattree {Size = "Large"},
new Ball {Color = "Yellow"},
};
}
public Dog(string _name, int _age, string _favFood, string _breed, bool _isHungry, List<Toy> _toyList)
: base(_name, _age, _favFood, _breed, _isHungry, _toyList)
{
Name = _name;
Age = _age;
FavFood = _favFood;
Breed = _breed;
IsHungry = _isHungry;
Toys = _toyList;
}