예제 #1
0
        public static void Main(string[] args)
        {
            SalesDetails obj = new SalesDetails();

            Console.WriteLine("Enter sales id ");
            obj.SalesId = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter customer name ");
            obj.CustomerName = Console.ReadLine();

            Console.WriteLine("Enter the number of units sold");
            obj.NoOfUnits = int.Parse(Console.ReadLine());



            Metalapps app = new Metalapps();

            app.CalculateNetAmount(obj);
            app.AddSalesDetails(obj);

            Console.WriteLine("Sales Bill ");
            Console.WriteLine("***********");
            Console.WriteLine("Sales Id : " + obj.SalesId);
            Console.WriteLine("Customer Name : " + obj.CustomerName);
            Console.WriteLine("Number of Units Sold : " + obj.NoOfUnits);
            Console.WriteLine("Net Amount : " + obj.NetAmount);
            //List<SalesDetails> l1 = new List<SalesDetails>();
            //l1=app.geList();
            //foreach (var item in l1)
            //{
            //    Console.WriteLine($"Sales Details of ID {((SalesDetails)item).SalesId} with name {((SalesDetails)item).CustomerName} has bought {((SalesDetails)item).NoOfUnits} with total of {((SalesDetails)item).NetAmount}");
            //}
            //Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args) //DO NOT change the 'Main' method signature
        {
            //Implement the code here
            int    salesId, NoOfUnits;
            string customerName;

            Console.WriteLine("Enter sales id");
            salesId = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter customer name");
            customerName = Console.ReadLine();
            Console.WriteLine("Enter the number of units sold");
            NoOfUnits = int.Parse(Console.ReadLine());
            try
            {
                SalesDetails sd = new SalesDetails(salesId, customerName, NoOfUnits, 0);
                Metalapps    mp = new Metalapps();
                mp.CalculateNetAmount(sd);
                mp.AddSalesDetails(sd);
                Console.WriteLine("Sales Bill\n***********\n");
                Console.WriteLine("Sales Id:" + sd.SalesId);
                Console.WriteLine("Customer Name :" + sd.CustomerName);
                Console.WriteLine("Number of Units Sold :" + sd.NoOfUnits);
                Console.WriteLine("Net Amount :" + sd.NetAmount);
            }
            catch (ArgumentOutOfRangeException e)
            {
                Console.WriteLine(e);
            }
            Console.ReadLine();
        }