How can I create a new instance of Boeing737 and use it later in the program. For example I want to be able to create 5 Boeings, do I have to define them like
Boeing737 boeing1 = new Boeing737(name: "Boeing737" + Console.ReadLine(),fuel: int.Parse(Console.ReadLine()) , tons: 0);
Boeing737 boeing2 = new Boeing737(name: "Boeing737" + Console.ReadLine(),fuel: int.Parse(Console.ReadLine()) , tons: 0);
and so on... Or is there easier way? Other question, to WHAT can I assign all the properties of boeing1 for example?
Here is my current code:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Insert the type of boeing that u are using");
Boeing737 boeing = new Boeing737(name: "Boeing737" + Console.ReadLine(),fuel: int.Parse(Console.ReadLine()) , tons: 0);
Console.WriteLine("{0} has {1} tons of fuel and weights {2}", boeing.Name, boeing.Fuel, boeing.Tons);
Console.ReadKey();
}
}
public class Planes
{
public Planes(string name, int fuel, int tons)
{
Name = name;
Fuel = fuel;
Tons = tons;
}
public int Tons;
public int Fuel;
public string Name { private set; get; }
}
class Boeing737 : Planes
{
public Boeing737(string name, int fuel, int tons) : base(name, fuel, tons)
{
Tons = 700;
}
}
}
Console.ReadLine()within the constructor (let alone twice). Make that a separate call, capture the output, and use that in the constructor.C# Basics Tutorialfocus on variables, classes, encapsulation, propertiesboeing that u are using