public string FName { get; set; }
public string Lname { get; set; }
public OrderInfo[] orderInfo;
public float Price { get; set; }
public int Order_Qty { get; set; }
public Vehicle vehicle { get; set; }
public string Description { get; set; }
public int Wheels { get; set; }
public int HorsePower { get; set; }
public virtual double CargoCap() { return 0; }
public class Automobile : Vehicle
public double Cargo_Capacity, Length, Width, Height;
public override double CargoCap()
Cargo_Capacity = Length * Width * Height;
return Math.Round(Cargo_Capacity, 2);
public class Motorcycle : Vehicle
public double Cargo_Capacity, Radius, Height;
public override double CargoCap()
Cargo_Capacity = (Math.PI * (Radius * Radius) * Height) * 2;
return Math.Round(Cargo_Capacity, 2);
public static void Main(string[] args)
StreamWriter streamwriter;
TextWriter oldOut = Console.Out;
outstream = new FileStream("./Output.txt", FileMode.OpenOrCreate, FileAccess.Write);
streamwriter = new StreamWriter(outstream);
Console.WriteLine("Oops! Cannot open text file for writing");
Console.WriteLine(e.Message);
CustInfo[] customer = new CustInfo[10];
CustInfo customer1 = new CustInfo { FName = "Henry", Lname = "Desusa", orderInfo = new OrderInfo[1] };
OrderInfo Cust1item1 = new OrderInfo { Order_Qty = 1, Price = 10000, vehicle = new Motorcycle { Radius = 10, Height = 2, Description = "Herley Davidson- Iron 883", HorsePower = 15 } };
customer1.orderInfo[0] = Cust1item1;
CustInfo customer2 = new CustInfo { FName = "Joe", Lname = "Cowdry", orderInfo = new OrderInfo[2] };
OrderInfo Cust2item1 = new OrderInfo { Order_Qty = 1, Price = 45000, vehicle = new Automobile { Length = 5, Width = 3, Height = 2, Description = "Ferrari 458", HorsePower = 50 } };
customer2.orderInfo[0] = Cust2item1;
OrderInfo Cust2item2 = new OrderInfo { Order_Qty = 1, Price = 21000, vehicle = new Motorcycle { Radius = 5, Height = 5, Description = "Honda- GOLD WING F6B", HorsePower = 20 } };
customer2.orderInfo[1] = Cust2item2;
Console.WriteLine("\n\n\n\n\t\t\tOrder Information Form\n\n");
Console.Write("\n\t\t\t----------------------\n\n\n");
for (int i = 0; i < customer.Length; i++)
Console.WriteLine("\n\n");
Console.Write("\n****-------New Customer-------****\n\n\n");
Console.WriteLine("\nCustomer Name: {0} {1}\n", customer[i].FName, customer[i].Lname);
Console.WriteLine("\n----------------------------\n");
for (int j = 0; j < customer[i].orderInfo.Length; j++)
if (customer[i].orderInfo[j] != null)
Console.WriteLine("\nDescription: {0}", customer[i].orderInfo[j].vehicle.Description);
Console.WriteLine("------------");
Console.WriteLine("\nPrice\t\tQuantity\tHorse Power\tCargoCapacity\n");
Console.WriteLine("{0:C2}\t{1}\t\t{2}\t\t{3}\n\n",
customer[i].orderInfo[j].Price, customer[i].orderInfo[j].Order_Qty, customer[i].orderInfo[j].vehicle.HorsePower, customer[i].orderInfo[j].vehicle.CargoCap());
Console.WriteLine("Please check the file Output.txt in Project Folder for Output");