コード例 #1
0
    public static void Main(string[] args)
    {
        Console.WriteLine("1.Add Customer");
        Console.WriteLine("2.Display Customer");
        Console.WriteLine("3.Search Customer");
        Console.WriteLine("4.Delete Customer");

        CustomerUtility cu = new CustomerUtility();

        for (int i = 0; i <= 3; i++)
        {
            Console.WriteLine("enter your Choice");
            int choice = int.Parse(Console.ReadLine());

            if (choice == 1)
            {
                Console.WriteLine("Enter Customer id, name and city");
                int    id   = int.Parse(Console.ReadLine());
                string name = Console.ReadLine();
                string city = Console.ReadLine();

                Customer c = new Customer(id, name, city);
                cu.AddCustomer(c);
            }

            if (choice == 2)
            {
                if (cu.custList.Count != 0)
                {
                    cu.DisplayAllCustomers();
                }
            }

            if (choice == 3)
            {
                int idd = int.Parse(Console.ReadLine());
                cu.DisplayAllCustomers();
                Customer c = cu.SearchCustomerByID(idd);
                if (c != null)
                {
                    Console.WriteLine("{0} {1} {2}", c.Id, c.Name, c.City);
                }
            }

            if (choice == 4)
            {
                int id = int.Parse(Console.ReadLine());
                cu.DeleteCustomer(id);
            }
        }
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: siddlal/Accenture-Tekstac
    public static void Main(string[] args) //DO NOT change the 'Main' method signature
    {
        //code need to be written
        CustomerUtility cu = new CustomerUtility();
        int             ch = 0, id;
        List <Customer> l;

        while (ch != 5)
        {
            Console.WriteLine("1. Add Customer\n2. Display Customer\n3. Search Customer\n4.Delete Customer\n5.Exit\nEnter Your Choice");
            ch = Convert.ToInt32(Console.ReadLine());
            switch (ch)
            {
            case 1: {
                Customer obj = new Customer();
                Console.WriteLine("Enter Customer id, name and city");
                obj.Id   = Convert.ToInt32(Console.ReadLine());
                obj.Name = Console.ReadLine();
                obj.City = Console.ReadLine();
                l        = cu.AddCustomer(obj);
                break;
            }

            case 2: {
                cu.DisplayAllCustomers();
                break;
            }

            case 3: {
                Console.WriteLine("Enter Customer Id");
                id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(cu.SearchCustomerByID(id));
                break;
            }

            case 4: {
                id = Convert.ToInt32(Console.ReadLine());
                cu.DeleteCustomer(id);
                break;
            }

            case 5: break;
            }
        }
    }