Пример #1
0
        static void Main(string[] args)
        {
            salcomm      sal          = new salcomm();
            Hourly       hourly       = new Hourly();
            Commissioned commissioned = new Commissioned();
            Salaried     salaried     = new Salaried();

            salaried.Name   = "B";
            salaried.Id     = 2;
            salaried.Salary = 15000;

            hourly.Name    = "C";
            hourly.Id      = 3;
            hourly.Hours   = 50;
            hourly.Payment = 400;

            commissioned.Name       = "D";
            commissioned.Id         = 4;
            commissioned.Articles   = 10;
            commissioned.Unit_price = 500;

            sal.Name       = "E";
            sal.Id         = 5;
            sal.Articles   = 10;
            sal.Unit_price = 500;
            sal.Salary     = 15000;

            Console.WriteLine(salaried.Id + "  " + salaried.Name + "  " + salaried.Salary);
            Console.WriteLine(hourly.Id + "  " + hourly.Name + "  " + hourly.getSalary());
            Console.WriteLine(commissioned.Id + "  " + commissioned.Name + "  " + commissioned.getCommision());
            Console.WriteLine(sal.Id + "  " + sal.Name + "  " + sal.getIncome());
        }
Пример #2
0
        static void Main(string[] args)
        {
            int            choice;
            Salaried       salaried       = new Salaried();
            Sal_Commission sal_Commission = new Sal_Commission();
            Commission     commission     = new Commission();
            Hourly         hourly         = new Hourly();

            try{
                do
                {
                    Console.WriteLine("Enter choice:");
                    Console.WriteLine("1.Salaried Employee");
                    Console.WriteLine("2.Hourly Employee");
                    Console.WriteLine("3.Commission Employee");
                    Console.WriteLine("4.Salaried Commission Employee");
                    Console.WriteLine("5.Exit");
                    choice = Convert.ToInt32(Console.ReadLine());
                    switch (choice)
                    {
                    case 1: salaried.setDetails();
                        Console.WriteLine("Salary Per Week: " + salaried.calsal().ToString());
                        break;

                    case 2: hourly.setDetails();
                        Console.WriteLine("Salary: " + hourly.calsal().ToString());
                        break;

                    case 3: commission.setDetails();
                        Console.WriteLine("Salary Per Week: " + commission.calsal().ToString());
                        break;

                    case 4: sal_Commission.setDetails();
                        Console.WriteLine("Salary Per Week: " + sal_Commission.calsal().ToString());
                        break;
                    }
                }while(choice != 5);
            }
            catch (MyException e) {
                Console.WriteLine(e.Message);
            }
            catch (FormatException e) {
                Console.WriteLine(e.Message);
            }
            catch (Exception e) {
                Console.WriteLine(e.Message);
            }
        }