static void Main(string[] args) { MotobikeAgent motobikeAgent = new MotobikeAgent(); int choice = 0; do { Console.WriteLine("1. Add"); Console.WriteLine("2. List"); Console.WriteLine("3. Search"); Console.WriteLine("4. Iswarrannty"); Console.WriteLine("5. quit"); choice = Wrappers.GetInt("Enter your choice: "); switch (choice) { case 1: BuyMotobikeCustomer bmc = GetBuyMotobikeCustomer(); motobikeAgent.Add(bmc); break; case 2: List(motobikeAgent); break; case 3: if (motobikeAgent.GetCount() == 0) { Console.WriteLine("List is empty"); } else { string name = Wrappers.GetString("Enter customer name: "); Search(name, motobikeAgent); } break; case 4: if (motobikeAgent.GetCount() == 0) { Console.WriteLine("List is empty"); } else { string namecus = Wrappers.GetString("Enter customer name: "); string code = Wrappers.GetString("Enter motobike code: "); Iswarranty(namecus, code, motobikeAgent); } break; case 5: Environment.Exit(0); break; default: Console.WriteLine("Invalid your choice"); break; } } while (true); }
public static void List(MotobikeAgent mbAgent) { if (mbAgent.GetCount() == 0) { Console.WriteLine("List is empty"); } else { foreach (BuyMotobikeCustomer bmc in mbAgent.MotobikeList) { Console.WriteLine("{0}\t\t{1}\n{2}\t\t{3}", bmc.Name, bmc.Address, bmc.Phone, bmc.Email); Console.WriteLine("{0,-10}{1,-20}{2,-10}{3,-15}{4,-5}{5,-15}", bmc.BuyMotobike.Code, bmc.BuyMotobike.Name, bmc.BuyMotobike.Price, bmc.BuyMotobike.Type, bmc.BuyMotobike.Warranty, bmc.BuyMotobike.SaleDate); } } }