Exemplo n.º 1
0
        static void Main(string[] args)
        {
            List <Employee> employees = new List <Employee>();

            Console.Write("Enter the number of employees: ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Employee #{i} data: ");
                Console.Write("Outsourced (y/n): ");
                char outsourced = char.Parse(Console.ReadLine());
                Console.Write("Name: ");
                string name = Console.ReadLine();
                Console.Write("Hours: ");
                int hours = int.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine());

                if (outsourced == 'y')
                {
                    Console.Write("Additional Charge: ");
                    double            addCharge         = double.Parse(Console.ReadLine());
                    OutSourceEmployee employeeOutSource = new OutSourceEmployee(name, hours, valuePerHour, addCharge);
                    employees.Add(employeeOutSource);
                }
                else
                {
                    Employee employ = new Employee(name, hours, valuePerHour);
                    employees.Add(employ);
                }
                Console.WriteLine();
            }

            foreach (Employee item in employees)
            {
                Console.WriteLine("PAYMENTS: ");
                Console.WriteLine("Nome: " + item.Name + " - $ " + item.Payment());
            }

            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            List <Employee> employees = new List <Employee>();

            Console.Write("Enter the number of employees:");
            int numberEmployees = int.Parse(Console.ReadLine());

            for (int i = 1; i <= numberEmployees; i++)
            {
                Console.WriteLine($"Employee #{i} data: ");
                Console.Write("Outsourced (Y/n)? ");
                char answerOutsourced = char.Parse(Console.ReadLine());

                Console.Write("Name: ");
                string name = Console.ReadLine();
                Console.Write("Hours: ");
                int hours = int.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valueHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

                if (answerOutsourced == 'y' || answerOutsourced == 'Y')
                {
                    Console.Write("Additional charge: ");
                    double additionalCharge = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

                    Employee employeeOutsourced = new OutSourceEmployee(name, hours, valueHour, additionalCharge);

                    employees.Add(employeeOutsourced);
                }
                else
                {
                    Employee employee = new Employee(name, hours, valueHour);
                    employees.Add(employee);
                }
            }

            Console.WriteLine("PAYMENTS:");
            foreach (Employee item in employees)
            {
                Console.WriteLine($"{item.Name} - $ {item.Payment().ToString("F2", CultureInfo.InvariantCulture)}");
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.Write("Enter the number of employees: ");
            int             N         = int.Parse(Console.ReadLine());
            List <Employee> employees = new List <Employee>();

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine("Employee #" + (i + 1) + " data:");
                Console.Write("Outsourced (y/n)? ");
                string response = Console.ReadLine();
                response = response.ToUpper();
                bool outsourced = response == "Y";
                Console.Write("Name: ");
                string name = Console.ReadLine();
                Console.Write("Hours: ");
                int hours = int.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valueperhours    = double.Parse(Console.ReadLine());
                double additionalcharge = 0;
                if (outsourced == true)
                {
                    Console.Write("Additional charge: ");
                    additionalcharge = double.Parse(Console.ReadLine());
                    Employee employee = new OutSourceEmployee(name, hours, valueperhours, additionalcharge);
                    employees.Add(employee);
                }

                else
                {
                    Employee employee = new Employee(name, hours, valueperhours);
                    employees.Add(employee);
                }
            }
            Console.WriteLine();
            Console.WriteLine("Payments:");
            foreach (Employee x in employees)
            {
                Console.WriteLine(x);
            }
        }