public static void Main()
Customer[] customerSavedArray = new Customer[3];
Order or11 = new Order(25000.00, 4, new Automobile());
Order or12 = new Order(15000, 3, new Motorcycle());
IOrder[] Order121 = new Order[2];
customerSavedArray[0] = new Customer("Jane", "Doe", Order121);
or11 = new Order(10000, 3, new Automobile());
customerSavedArray[1] = new Customer("John", "Smith",Order121);
or11 = new Order(18000, 2, new Motorcycle());
customerSavedArray[2] = new Customer("Mary", "A J", Order121);
WriteData(customerSavedArray);
private static void WriteData(Customer[] customerArr)
StreamWriter sw = new StreamWriter("c:\\ResultofAssignment3.txt", false);
foreach (Customer cust in customerArr)
sw.WriteLine("************************************************************");
sw.WriteLine(cust.WriteCustomer());
if (cust.CustomerOrders.Length > 0)
foreach (Order or in cust.CustomerOrders)
sw.WriteLine(or.WriteOrder());
sw.WriteLine("************************************************************");
public interface ICustomer
public class Customer : ICustomer
private string _firstName;
private string _lastName;
public IOrder[] CustomerOrders;
public Customer(string FirstName, string LastName,IOrder[] Orders)
public string WriteCustomer()
return ("Customer : " + _firstName + " " + _lastName).ToString();
public class Order : IOrder
private IVehicle _vehicle;
public Order(double Price,int Qnty,IVehicle Vehicle)
public string WriteOrder()
return (_vehicle.VehicleType + " - " + _price.ToString("C") + " - " + _qnty.ToString() + " - " + _vehicle.CargoCapacity()).ToString();
public interface IVehicle
string Description { get; set; }
string HorsePower { get; set; }
string VehicleType { get; set; }
public class Automobile : IVehicle
public double CargoCapacity()
double Auto = (length * width * height);
public int Wheels { get; set; }
public string Description { get; set; }
public string HorsePower { get; set; }
public string VehicleType
get { return "AutoMobile"; }
public class Motorcycle : IVehicle
public double CargoCapacity()
double Motor = (pi * (radius * radius) * height) * 2;
public int Wheels { get; set; }
public string Description { get; set; }
public string HorsePower { get; set; }
public string VehicleType
get { return "Motorcycle"; }