A newcommer's question:
I made a small (incomplete) program and cannt get it to compile. I get the error:
"Error 1 'Animals1.Zoo' does not contain a constructor that takes '4' arguments".
I belive I made all constructors as I should, but still can't get it to run.
What am I doing wrong?
Here it is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Animals1
{
//This is the base class for all Animals
abstract public class Zoo
{
//Defs:
string AnimalName;
int AnimalID;
String AnimalCryOut;
Decimal AverageWheight;
// Default ctor.
public Zoo() { }
// Custom ctor
public void Elephant(string AnimalName, int AnimalID, String AnimalCryOut, Decimal AverageWheight)
{
this.AnimalName = AnimalName;
this.AnimalID = AnimalID;
this.AnimalCryOut = AnimalCryOut;
this.AverageWheight = AverageWheight;
}
public virtual void DisplayInfo()
{
Console.WriteLine("Name: {0}", AnimalName);
Console.WriteLine("ID: {0}", AnimalID);
Console.WriteLine("Shout: {0}", AnimalCryOut);
Console.WriteLine("Wheight: {0}", AverageWheight);
return;
}
}
//======================
class Elephant : Zoo
{
public Elephant() { }
public Elephant(string AnimalName, int AnimalID, String AnimalCryOut, Decimal AverageWheight)
: base(AnimalName, AnimalID, AnimalCryOut, AverageWheight)
{
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine("Elephant Info");
}
}
//==========================
class Program
{
static void Main(string[] args)
{
Elephant Dumbo = new Elephant("Dumbo", 1001, "Ahooo...", 3400);
//Snake Sleeky = new Snake("Sleeky", 2002, "Ahooo...", 2);
//Fish Wanda = new Fish("Wanda", 3003, "", 12);
}
}
}