public static void Main()
CustInfo[] customer = new CustInfo[2];
CustInfo customer1 = new CustInfo { FName = "Joe", Lname = "Smith", orderInfo = new OrderInfo[1] };
OrderInfo Cust1item1 = new OrderInfo { Order_Qty = 1, Price = 10000, vehicle = new Motorcycle { Radius = 9, Height = 2, Description = "Black", 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 = "Red", HorsePower = 50 } };
customer2.orderInfo[0] = Cust2item1;
OrderInfo Cust2item2 = new OrderInfo { Order_Qty = 1, Price = 21000, vehicle = new Motorcycle { Radius = 5, Height = 5, Description = "Metallic", HorsePower = 20 } };
customer2.orderInfo[1] = Cust2item2;
using (StreamWriter writer = new StreamWriter("important.txt"))
for (int i = 0; i < customer.Length; i++)
writer.Write("\n-------New Customer-------\n\n\n");
writer.Write("Customer Name: {0} {1}\n", customer[i].FName, customer[i].Lname);
writer.Write("----------------------------\n");
for (int j = 0; j < customer[i].orderInfo.Length; j++)
writer.Write("Description: {0}", customer[i].orderInfo[j].vehicle.Description);
writer.Write("------------");
writer.Write("\nPrice\t\tQuantity\tHorse Power\tCargoCapacity\n");
writer.Write("{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());
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);