I am trying to implement an interface and use its methods, but when I create a Star object and try and use methods, they don't print anything.
Fair warning, I have not been coding for months, and I'm very new to C#(about a week in) so this is horrendous.
Any help on any issues in this code would be greatly appreciated
The first part of my code:
interface CelestialBody
{
string getName();
string getType();
List<string> getOrbitals();
void addOrbitals(string Orbital);
}
enum CelestialBodyType { Star, Planet, Satellite }
class Star : CelestialBody
{
private string _Name;
private List<string> Planets;
private readonly string Type = "Star";
public string getType() { return Type; } // Planet, Sun, Satellite
public string Name
{
set
{
_Name = value;
}
get
{
return _Name;
}
}
public string getName() { return _Name; }
public List<string> getOrbitals() { return Planets; }
public void addOrbitals(string NewPlanet) { Planets.Add(NewPlanet); }
public Star() : this("No Name") // Sets the default value of Name
{
}
public Star(string Name) : this(Name, CelestialBodyType.Star) // Set the default value of Classification
{
}
//Designated Constructor
public Star(string Name, CelestialBodyType Star)
{
this.Name = Name;
}
}
}
The main part of my code
class Program
{
static void Main(string[] args)
{
Star star = new Star("The Sun");
Console.Write(star.getName() + star.getType());
}
}
}