Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.Write("Enter department´s name: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Enter worker data:");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base Salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            //instanciando o objeto Departamento
            Department dept = new Department(deptName);

            //instanciando o objeto Worker
            Worker worker = new Worker(name, level, baseSalary, dept); //dept é o instanciado acima

            Console.WriteLine();
            Console.Write("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine();
                Console.WriteLine($"Enter #{i + 1} contract data: ");
                Console.Write("Data (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duration (hours): ");
                int hours = int.Parse(Console.ReadLine());
                //instanciando um novo contrato
                HourContract contract = new HourContract(date, valuePerHour, hours);
                //adicionando um contrato ao trabalhador
                worker.AddContract(contract);
            }

            Console.WriteLine();
            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine();
            Console.WriteLine("** WORKER SUMARY **");
            Console.WriteLine($"Name              : {worker.Name}");
            Console.WriteLine($"Department        : {worker.Department.Name}");
            Console.WriteLine($"Income for {monthAndYear}: {worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture)}");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.Write("Enter departmenet's name: ");
            string dpName = Console.ReadLine();

            Console.WriteLine("Enter worker data: ");
            Console.Write("Name: ");
            string wkName = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            WorkerLevel wkLevel = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            // instancia de department
            Department dept = new Department(dpName);

            // instanciando work e relacionando work com department
            Worker work = new Worker(wkName, wkLevel, baseSalary, dept);

            Console.Write("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine($"Enter #{i+1} contract data: ");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());

                Console.Write("Value per hour: ");
                double valueHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duration (hours): ");
                int durationHours = int.Parse(Console.ReadLine());


                //intanciando um novo contrato, com data, valorHora, e duracao
                HourContract contract = new HourContract(date, valueHour, durationHours);

                //adcionar um contrato para um trabalhador
                work.AddContract(contract);
            }

            Console.WriteLine();
            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine("Name: " + work.Name);
            Console.WriteLine("Department: " + work.Department.Name);
            Console.WriteLine("Income for: " + monthAndYear + ": " + work.Income(year, month).ToString("F2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.Write("Enter department's name: ");
            string department = Console.ReadLine();

            Console.WriteLine("Enter worker data:");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");

            WorkerLevel level = (WorkerLevel)Enum.Parse(typeof(WorkerLevel), Console.ReadLine());

            Console.Write("Base salary: ");
            double salary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Department dept = new Department(department);

            Worker worker = new Worker(name, level, salary, dept);

            Console.Write("How many contracts to this worker? ");
            int numberOfContracts = int.Parse(Console.ReadLine());

            for (int i = 1; i <= numberOfContracts; i++)
            {
                Console.WriteLine("Enter #" + i + " contract data:");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duration (hours): ");
                int          hours    = int.Parse(Console.ReadLine());
                HourContract contract = new HourContract(date, valuePerHour, hours);
                worker.AddContract(contract);
            }
            Console.WriteLine();
            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string[] read  = Console.ReadLine().Split('/');
            int      month = int.Parse(read[0]);
            int      year  = int.Parse(read[1]);

            Console.WriteLine("Name: " + name);
            Console.WriteLine("Department: " + department);

            if (month < 10)
            {
                Console.WriteLine("Income for " + "0" + month + "/" + year + ": " + worker.Income(year, month));
            }
            else
            {
                Console.WriteLine("Income for " + month + "/" + year + ": " + worker.Income(year, month));
            }
        }
Exemplo n.º 4
0
        public Worker(string name, WorkerLevel level, double baseSalary, Department department)
        {
            Name       = name;
            Level      = level;
            BaseSalary = baseSalary;
            Department = department;

            /*
             *  Não incluir as associações para muitos(Contracts/List/Array), porque não
             *  é usual que se passe uma lista instânciada num construtor de um objeto.
             */
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //Getting worker data
            Console.Write("Enter department's name: ");
            string departmentName = Console.ReadLine();

            Console.WriteLine("Enter worker data:");
            Console.Write("Name: ");
            string workerName = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base Salary: ");
            double baseSalary = double.Parse(Console.ReadLine());
            //instancing department
            Department dept = new Department(departmentName);
            //instancing worker with worker data above
            Worker worker = new Worker(workerName, level, baseSalary, dept);

            //getting number of contracts
            Console.Write("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            //getting n contracts data
            for (int i = 1; i <= n; i++)
            {
                //getting contract obe contract data
                Console.WriteLine($"Enter #{i} contract data:");//inserção concatenação por interpolação
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine());
                Console.Write("Duration (hours): ");
                int duration = int.Parse(Console.ReadLine());
                //instancing contract with collected data above
                HourContract contract = new HourContract(date, valuePerHour, duration);
                //Calling method AddContract() of the worker instance.
                worker.AddContract(contract);
            }

            Console.WriteLine();
            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3, 4));

            //Final Display
            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + worker.Department.Name);
            Console.WriteLine("Income for " + monthAndYear + ": " + worker.Income(year, month).ToString("C", CultureInfo.CreateSpecificCulture("pt-BR")));
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            //Order order = new Order(1, DateTime.Now, OrderStatus.PendingPayment);
            //Console.WriteLine(order.ToString());

            Console.Write("Enter derpartment's name: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Enter worker data: ");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            WorkerLevel level = (WorkerLevel)Enum.Parse(typeof(WorkerLevel), Console.ReadLine());

            Console.Write("Base Salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Department department = new Department(deptName);
            Worker     worker     = new Worker(name, level, baseSalary, department);

            Console.Write("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine($"Enter #{i + 1} contract data: ");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine());
                Console.Write("Duration (hours): ");
                int hours = int.Parse(Console.ReadLine());

                HourContract contract = new HourContract(date, valuePerHour, hours);

                worker.AddContract(contract);

                Console.WriteLine();
            }

            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine($"Name: {worker.Name}");
            Console.WriteLine($"Departament: {worker.Department.Name}");
            Console.WriteLine($"Income for {monthAndYear}: {worker.Income(month, year).ToString("F2", CultureInfo.InvariantCulture)}");

            Console.ReadKey();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Console.Write("Enter department's name: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Enter worker data: ");
            Console.Write("Name:");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            WorkerLevel level = new WorkerLevel();

            try
            {
                level = (WorkerLevel)Enum.Parse(typeof(WorkerLevel), Console.ReadLine());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Departament dept   = new Departament(deptName);
            Worker      worker = new Worker(name, level, baseSalary, dept);

            Console.WriteLine("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i < n; i++)
            {
                Console.WriteLine($"Enter #{i} contract data:");
                Console.Write("Data (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.WriteLine("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.WriteLine("Duration (hours)");
                int          hours    = int.Parse(Console.ReadLine());
                HourContract contract = new HourContract(date, valuePerHour, hours);

                worker.AddContract(contract);
            }

            Console.WriteLine("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Departament: " + worker.Departament.Name);
            Console.WriteLine("Income for " + monthAndYear + ": " + worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter department's name");
            string dept = Console.ReadLine();

            Console.WriteLine("Enter worker data");
            Console.WriteLine("Name");
            string name = Console.ReadLine();

            Console.WriteLine("Level: JUNIOR, MIDLEVEL OR SENIOR");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine().ToUpper());

            Console.WriteLine("Base Salary:");
            double salario = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Department d = new Department(dept);
            Worker     t = new Worker(name, level, salario, d);

            Console.WriteLine("How many contracts to this worker");
            int n = Convert.ToInt32(Console.ReadLine());



            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Enter #{i} contract data:");
                Console.WriteLine("Date (DD)/MM/YYYY):");
                DateTime data = DateTime.Parse(Console.ReadLine());
                Console.WriteLine("Value per hour");
                double value = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.WriteLine("Duration(HRS)");
                int hrs = int.Parse(Console.ReadLine());

                HourContract contrato = new HourContract(data, value, hrs);

                t.AddContract(contrato);


                Console.WriteLine($" Contract Validation Code:{Guid.NewGuid()}");
            }

            Console.WriteLine();
            Console.WriteLine("Enter the date to calculate MM/YY");
            string mesEano = Console.ReadLine();
            int    month   = int.Parse(mesEano.Substring(0, 2));
            int    year    = int.Parse(mesEano.Substring(3));


            Console.WriteLine($"Name: {t.Name}");
            Console.WriteLine($"Department:{t.Department.Name}");
            Console.WriteLine($"Income: {t.Income(month, year)}");
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            Console.Write("Enter department's name: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Enter worker data:");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            //Convertendo a string recebida em um objeto parametrizado na enumeração
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            /*Depois de recebidos os dados de departamento e do trabalhador, podemos
             * instanciar um objeto do tipo Department e então um objeto do tipo Worker*/
            Department dept   = new Department(deptName);
            Worker     worker = new Worker(name, level, baseSalary, dept);

            Console.Write("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Enter #{i} contract data:");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duration (hours): ");
                int hours = int.Parse(Console.ReadLine());

                /*Fornecidos os dados de contrato, podemos instanciar um objeto do tipo
                 * HourContract*/
                HourContract contract = new HourContract(date, valuePerHour, hours);

                /*Agora que temos os dados de um contrato, podemos adicionar à lista de
                 * contratos por meio do método worker.addContract*/
                worker.addContract(contract);
            }
            Console.WriteLine();
            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + worker.Department.Name);
            Console.WriteLine("Income for " + monthAndYear + ": " + worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 10
0
        public static void Display()
        {
            Console.Write("Enter Department's name: ");
            string deptName = Console.ReadLine(); //Alterei, pois imagino que depois seja ideal separar o view da criação de objetos (?)

            Console.WriteLine("Enter worker data -");

            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("How many contracts to this worker: ");
            int numberOfContracts = int.Parse(Console.ReadLine());

            Department dept   = new Department(deptName);
            Worker     worker = new Worker(name, level, baseSalary, dept);

            for (int i = 0; i < numberOfContracts; i++)
            {
                DateTime date;
                double   valuePerHour;
                int      hours;

                Console.WriteLine($"Enter #{i+1} contract data:");

                Console.Write("Date (DD/MM/YYYY): ");
                date = DateTime.Parse(Console.ReadLine());

                Console.Write("Value per hour: ");
                valuePerHour = double.Parse(Console.ReadLine());

                Console.Write("Duration (hours): ");
                hours = int.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

                worker.AddContract(new HourContract(date, valuePerHour, hours)); //ele separa a criação do objeto contract e a adição dele na lista
            }

            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            DateTime calculateIncomeDate = DateTime.Parse(Console.ReadLine());


            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + worker.Department.Name);
            Console.WriteLine("Income for "
                              + calculateIncomeDate.Month + "/" + calculateIncomeDate.Year + ": "
                              + worker.Income(calculateIncomeDate.Year, calculateIncomeDate.Month).ToString("F2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Console.Write("Enter the department's name: ");
            string departmentName = Console.ReadLine();

            Console.WriteLine("Enter worker data: ");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior / MidLevel / Senior): ");
            WorkerLevel level = (WorkerLevel)Enum.Parse(typeof(WorkerLevel), Console.ReadLine());

            Console.Write("Base salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Department department = new Department(departmentName);
            Worker     worker     = new Worker(name, level, baseSalary, department);

            Console.Write("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Enter #{i} contract data:");

                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());

                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

                Console.Write("Duration (hours): ");
                int hour = int.Parse(Console.ReadLine());

                HourContract contract = new HourContract(date, valuePerHour, hour);
                worker.AddContract(contract);
            }

            Console.WriteLine();

            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();

            int month = int.Parse(monthAndYear.Split('/')[0]);
            int year  = int.Parse(monthAndYear.Split('/')[1]);

            Console.WriteLine($"Name: {worker.Name}");
            Console.WriteLine($"Department: {worker.Department.Name}");
            Console.WriteLine($"Income for {monthAndYear}: {worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture)}");

            Console.ReadLine();
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            CultureInfo CI = CultureInfo.InvariantCulture;

            Console.Write("Enter department's name = ");
            string deptName = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine("Enter Worker's data: ");
            Console.Write("Name = ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior) = ");
            WorkerLevel Level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base Salary = ");
            double baseSalary = double.Parse(Console.ReadLine(), CI);

            Department dept   = new Department(deptName);
            Worker     worker = new Worker(name, Level, baseSalary, dept);

            Console.WriteLine();
            Console.Write("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Enter #{i} contract data: ");
                Console.Write("Date (DD/MM/YYYY) = ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour = ");
                double valuePerHour = double.Parse(Console.ReadLine(), CI);
                Console.Write("Duration (hours) = ");
                int          hour     = int.Parse(Console.ReadLine());
                HourContract contract = new HourContract(date, valuePerHour, hour);
                worker.AddContract(contract);
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.Write("Enter month  and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine();
            Console.WriteLine("Worker's data and income");
            Console.WriteLine("Name = " + worker.Name);
            Console.WriteLine("Department = " + worker.Department.Name);
            Console.WriteLine("Income for " + monthAndYear + ": "
                              + worker.Income(year, month).ToString("F2", CI));
        }
Exemplo n.º 13
0
        public Worker(string name, WorkerLevel level, double baseSalary, Department department)

        {
            Name = name;

            Level = level;

            BaseSalary = baseSalary;

            Department = department;

            Contracts = new List <HourContract>();
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            Console.Write(" Enter department's name: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Enter worker data: ");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior)");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base Salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            // instancia objetos
            Department dept   = new Department(deptName);
            Worker     worker = new Worker(name, level, baseSalary, dept);

            Console.Write("How many contracts to this Worker: ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                // $"Enter #{i} interpolação
                Console.Write($"Enter #{i} contract data: ");
                Console.Write("Date (DD/MM/YYY: ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per House: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.WriteLine("Durations (Hours): ");
                int hours = int.Parse(Console.ReadLine());

                //instanciar contrato
                HourContract contract = new HourContract(date, valuePerHour, hours);

                // add contrato ao trabalhador
                worker.AddContract(contract);
            }

            Console.WriteLine();
            Console.Write("Enter month and year to calculate income (MM/YYYY)");
            string monthAndYear = Console.ReadLine();

            int month = int.Parse(monthAndYear.Substring(0, 2));
            int year  = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + worker.Department.Name);
            Console.WriteLine("income for: " + monthAndYear + " : " + worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            Console.Write("Enter Departament's name: ");
            string deptName = Console.ReadLine();

            Console.Write("Enter Worker data: ");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            //estou recebendo os dados de uma enumeração e convertendo para string.
            Console.Write("Level (Junior/MidLevel/Senior) ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base Salary: ");
            double salary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Departament dept   = new Departament(deptName);
            Worker      worker = new Worker(name, level, salary, dept);

            Console.Write("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Enter {i} contract data:");
                Console.Write("Date (DD/MM/YYYY) ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value Per Hour: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duration (hours): ");
                int hours = int.Parse(Console.ReadLine());

                HourContract contract = new HourContract(date, valuePerHour, hours);
                worker.AddContracts(contract);
            }

            Console.WriteLine();
            Console.Write("Enter month and year to calculate income (MM/YYYY): ");

            string monthAndYear = Console.ReadLine();

            int month = int.Parse(monthAndYear.Substring(0, 2));
            int year  = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Departament: " + worker.Departament.Name);
            Console.Write("Income for: " + monthAndYear + ": " + worker.Income(year, month).ToString("F2"), CultureInfo.InvariantCulture);


            Console.ReadLine();
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Entre com o nome do departamento");
            string departmentName = Console.ReadLine();

            Console.WriteLine("--------------------------------");
            Console.WriteLine("Dados do trabalhador");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/Pleno/Senior): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine().ToUpper());

            Console.Write("Salario: ");
            double salary = double.Parse(Console.ReadLine());

            Departmenrt departmenrt = new Departmenrt(departmentName);
            Worker      worker      = new Worker(name, level, salary, departmenrt);

            Console.Write("Quantos contratos o trabalhador tem? ");
            int contratos = int.Parse(Console.ReadLine());

            Console.WriteLine();

            for (int i = 1; i <= contratos; i++)
            {
                Console.WriteLine($"Informe os dados do #{i} contrato:");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Valor por hora: ");
                double valorHora = double.Parse(Console.ReadLine());
                Console.Write("Duração: ");
                int duracao = int.Parse(Console.ReadLine());

                HourContract contrato = new HourContract(date, valorHora, duracao);

                worker.AddContract(contrato);
            }
            Console.WriteLine();

            Console.Write("Informe o mês e ando para calcular o income (MM/YYYY): ");
            string mesAno = Console.ReadLine();
            int    mes    = int.Parse(mesAno.Substring(0, 2));
            int    ano    = int.Parse(mesAno.Substring(3));

            Console.WriteLine($"Nome: {worker.Name}");
            Console.WriteLine($"Departamento: {worker.Department.Name}");
            var totalIncome = worker.Income(ano, mes);

            Console.WriteLine($"Income for {mes}/{ano}: {totalIncome}");
        }
        static void Main(string[] args)
        {
            // Nome do Departamento
            Console.Write("Enter department's name: ");
            string deptName = Console.ReadLine();

            // Recebendo Dados iniciais do Funcionário
            Console.WriteLine("Enter Worker data:");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            // Composição entre as classe Worker e Department
            Department department = new Department(deptName);
            Worker     worker     = new Worker(name, level, baseSalary, department);

            // Ler os contratos do Funcionário(Worker)
            Console.Write("How many contracts to this Worker?: ");
            int numContracts = int.Parse(Console.ReadLine());

            for (int i = 1; i <= numContracts; i++)
            {
                // Dados do Contrato
                Console.WriteLine($"Enter #{i} contract data"); //Interpolação
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Durations (hours): ");
                int hours = int.Parse(Console.ReadLine());

                HourContract contract = new HourContract(date, valuePerHour, hours); // Instanciando Contract
                worker.AddContract(contract);                                        // Adicionando este Contrato de trabalho ao Funcionário (Worker)
            }

            Console.WriteLine();
            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            // Imprimindo os resultados
            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + worker.Department.Name);
            Console.WriteLine("Income for " + monthAndYear + ": " + worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            Console.Write("Enter department's name: "); //Nome do departamento
            string deptName = Console.ReadLine();

            Console.WriteLine("Enter worker data: "); //Dados do trabalhador

            Console.Write("Name: ");                  //Nome
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): "); //Nível do trabalhador
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base Salary: "); //Salário Base
            double baseSalary = double.Parse(Console.ReadLine());

            Department dept   = new Department(deptName);
            Worker     worker = new Worker(name, level, baseSalary, dept);

            Console.Write("How many contracts to this worker? "); //Quantos contratos para esse trabalhador ?
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Enter #{i} contract data: ");
                Console.Write("Date (DD/MM/YYYY): ");
                string   data = Console.ReadLine();
                DateTime date = DateTime.Parse(data);
                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine());
                Console.Write("Duration: ");
                int time = int.Parse(Console.ReadLine());

                //Instanciando um contrato
                HourContract contract = new HourContract(date, valuePerHour, time);
                worker.AddContract(contract);
            }

            Console.WriteLine();
            //Entre com mes e ano para calcular quanto que o trabalhador ganhou no mes
            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string monthandYear = Console.ReadLine();
            //Vai pegar duas posições do que o usuário digitar a partir da posição 0 ou seja o início
            int month = int.Parse(monthandYear.Substring(0, 2));
            //Vai pegar da posição 3 até o final da string
            int year = int.Parse(monthandYear.Substring(3));

            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + worker.Department.Name);
            Console.WriteLine($"Income for {monthandYear}: " + worker.Income(year, month));
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            Console.Write("Digite o nome do departamento: ");
            string     auxDep = Console.ReadLine();
            Department d      = new Department(auxDep);

            Console.WriteLine("\nEntre com as informações do trabalhador");
            Console.Write("Nome: ");
            string auxName = Console.ReadLine();

            //conversao string-enum
            Console.Write("Nivel (Junior/MidLevel/Senior): ");
            WorkerLevel auxLvl = new WorkerLevel();

            Enum.TryParse(Console.ReadLine(), out auxLvl);

            Console.Write("Salario Base: ");
            double auxSalary = double.Parse(Console.ReadLine());

            Console.Write("Quantos contratos esse trabalhador possui? ");
            int quant = int.Parse(Console.ReadLine());

            Worker trabalhador = new Worker(auxName, auxLvl, auxSalary, d);

            DateTime auxdata;
            double   auxvalue;
            int      auxduration;

            for (int i = 1; i <= quant; i++)
            {
                Console.Clear();
                Console.WriteLine($"\nEntre com as informações do {i}º contrato:");
                Console.Write("Data (dd/MM/yyyy): ");
                auxdata = DateTime.Parse(Console.ReadLine());
                Console.Write("Valor por hora: ");
                auxvalue = double.Parse(Console.ReadLine());
                Console.Write("Duraçao em horas: ");
                auxduration = int.Parse(Console.ReadLine());

                trabalhador.AddContract(new HourContract(auxdata, auxvalue, auxduration));
            }

            Console.Write("\nEntre com um mes e ano (MM/yyyy) para calcular o ganho: ");
            string[] dados = Console.ReadLine().Split('/');

            Console.WriteLine($"\nNome: {trabalhador.Name}" +
                              $"\nDepartamento: {trabalhador.Department}" +
                              $"\nGanho: {trabalhador.Income(int.Parse(dados[0]), int.Parse(dados[1]))}");

            Console.ReadKey();
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            /*aula 121 Ler os dados de um trabalhador com N contratos(N fornecido pelo usuário).Depois, solicitar
             * do usuário um mês e mostrar qual foi o salário do funcionário nesse mês */
            Console.Write("Informe o nome do departamento: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Informe os dados do trabalhador: ");

            Console.Write("Nome: ");
            string workerName = Console.ReadLine();

            Console.Write("Nível(Junior/MidLevel/Senior): ");
            WorkerLevel workerLevel = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Salário Base: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Department dept   = new Department(deptName);
            Worker     worker = new Worker(workerName, workerLevel, baseSalary, dept);

            Console.Write("Quantos contratos para esse trabalhador: ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Entre com os dados do contrato #{i}");

                Console.Write("Data: ");
                DateTime date = DateTime.Parse(Console.ReadLine());

                Console.Write("Valor por hora: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

                Console.Write("Duração(horas): ");
                int hours = int.Parse(Console.ReadLine());

                HourContract hourContract = new HourContract(date, valuePerHour, hours);
                worker.AddContract(hourContract);
            }
            Console.WriteLine("Entre com o mês e ano para calcular o ganho no formato MM/YYYY");
            string mesAno = Console.ReadLine();

            int    mes    = int.Parse(mesAno.Substring(0, 2));
            int    ano    = int.Parse(mesAno.Substring(3));
            double income = worker.Income(ano, mes);

            Console.WriteLine("Trabalhador: " + worker.Name);
            Console.WriteLine("Departamento: " + worker.Department.Name);
            Console.WriteLine($"Ganho em {mesAno} : {income.ToString("F2")}");
        }
        static void Main(string[] args)
        {
            Console.Write("Enter department's name: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Enter worker data:");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine()); // vai converter o que o usuario digitar para workerlevel

            Console.Write("Base salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Department dept   = new Department(deptName);
            Worker     worker = new Worker(name, level, baseSalary, dept);

            Console.WriteLine();
            Console.Write("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            Console.WriteLine();
            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Enter #{i} contract data:");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duration (hours): ");
                int hours = int.Parse(Console.ReadLine());

                //instanciando um contrato e adicionando o contrato ao trabalhador (worker)
                HourContract contract = new HourContract(date, valuePerHour, hours);
                worker.AddContract(contract);
                Console.WriteLine("-------------------------------");
            }

            Console.WriteLine();
            Console.Write("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2)); // corta da primeira posicao duas casas e guarda com inteiro
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine();
            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + dept.Name);
            Console.WriteLine("Income for " + monthAndYear + ": " + worker.Income(year, month).ToString("f2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            Console.Write("Entre com o nome do Departamento: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Entre com os dados do trabalhador: ");
            Console.Write("Nome: ");
            string name = Console.ReadLine();

            Console.WriteLine("Nivel (Junior/Pleno/Senior): ");
            WorkerLevel level = (WorkerLevel)Enum.Parse(typeof(WorkerLevel), Console.ReadLine());

            Console.Write("Salário Base: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            // adicionando os dados recebidos aos objetos abaixo
            Department dept   = new Department(deptName);
            Worker     worker = new Worker(name, level, baseSalary, dept);

            Console.Write("Quantidade de contratos desse trabalhador? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Entre com os dados do #{i} contrato:");
                Console.Write("Data (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Valor por hora: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duração (horas): ");
                int hours = int.Parse(Console.ReadLine());
                Console.WriteLine();
                // adicionando dados ao trabalhador
                HourContract contract = new HourContract(date, valuePerHour, hours);
                worker.AddContract(contract);
            }

            Console.WriteLine();
            Console.Write("Entre com mês e ano para calcular o ganho (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            // Substring - captura uma parte da string
            int month = int.Parse(monthAndYear.Substring(0, 2));
            int year  = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine("Nome : " + worker.Name);
            Console.WriteLine("Departmento: " + worker.Department.Name);
            Console.WriteLine("Ganho em " + monthAndYear + ": " + worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture));

            Console.ReadKey();
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            Console.Write("Digite o nome do departamento: ");
            string deptName = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine("Entre com os dados do trabalhador: ");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Qual o Nivel do trabalhador (Junior/MidLevel/Senior): ");

            WorkerLevel workerLevel = new WorkerLevel();

            Enum.TryParse <WorkerLevel>(Console.ReadLine(), out workerLevel);

            Console.Write("Salário Base: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);


            Department dept   = new Department(deptName);
            Worker     worker = new Worker(name, workerLevel, baseSalary, dept);

            Console.Write("Quantos contratos tem esse trabalhador: #");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine();
                Console.WriteLine($"Entre com #{i} contrato: ");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Valor por Hora: $");
                double valuerPerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duração (Horas): ");
                int          hours    = int.Parse(Console.ReadLine());
                HourContract contract = new HourContract(date, valuerPerHour, hours);
                worker.AddContract(contract);
            }
            Console.WriteLine();

            Console.Write("Entre com mês e ano para calcular o ganho (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine($"Nome: {worker.Name}");
            Console.WriteLine($"Departamento: {worker.Department.Name}");
            Console.WriteLine($"Renda em {monthAndYear}: ${worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture)}");
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            Console.Write("Enter with departmet's data :");
            string departName = Console.ReadLine();

            Console.WriteLine("------------ Enter with worker data ---------------");
            Console.Write("Name from worker :");
            string nameWorker = Console.ReadLine();

            Console.Write("Level Worker(Junior / Pleno / Senior ) : ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base Salary : ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            //instanciando os elemementos de associações
            Department dept   = new Department(departName);
            Worker     worker = new Worker(nameWorker, baseSalary, level, dept);

            Console.Write("how many contract for that worker? :");
            int n = int.Parse(Console.ReadLine());

            //depois que definir a quantidade de trabalhadores precisamos criar a quantidade de contratos

            for (int i = 1; i < n; i++)
            {
                Console.WriteLine();
                Console.WriteLine($"Enter #{i} Contract data ");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                int value = int.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duraction (Hours): ");
                int hours = int.Parse(Console.ReadLine());
                //instanciando um contrato
                HourContract contract = new HourContract();
                worker.AddContract(contract);
            }

            //capturar somente o mês e o ano.
            Console.WriteLine("Enter with month and year to calculer income (MM/YYYY): ");
            string yearAndMonth = Console.ReadLine();
            int    month        = int.Parse(yearAndMonth.Substring(0, 2));
            int    year         = int.Parse(yearAndMonth.Substring(3));

            //Dice from worker
            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + worker.Department.Name);
            Console.WriteLine("Income for : " + yearAndMonth + " : " + worker.InCome(year, month), CultureInfo.InvariantCulture);
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Department's name: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Enter Worker data: ");
            Console.WriteLine("Name: ");
            string workerName = Console.ReadLine();

            Console.WriteLine("Level (Junior/MidLevel/Senior): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("BaseSalary: R$ ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Department dept = new Department(deptName);

            Worker worker = new Worker(workerName, level, baseSalary, dept);

            Console.WriteLine("How many contracts to this worker? ");
            int number = int.Parse(Console.ReadLine());

            for (int i = 1; i <= number; i++)
            {
                Console.WriteLine("Enter {0} contract data: ", i);
                Console.WriteLine("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());
                Console.Write("Value Per Hour: R$ ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.WriteLine("Duration (hours): ");
                int duration = int.Parse(Console.ReadLine());

                HourContract contract = new HourContract(date, valuePerHour, duration);

                worker.AddContract(contract);
            }

            Console.WriteLine("Enter month and year to calculate income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine("Name: " +
                              worker.Name +
                              " Department: + " +
                              worker.Department.Name +
                              " Income for " + monthAndYear + " : R$ " +
                              worker.Income(month, year)
                              );
        }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            Console.Write("Enter department's name: ");
            string deptname = Console.ReadLine();

            Console.WriteLine("Enter worker data:");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior):");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base salary: ");
            double salary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Department dept   = new Department(deptname);
            Worker     worker = new Worker(name, level, salary, dept);

            Console.WriteLine("How many contracts to this worker? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                try {
                    Console.WriteLine($"Enter #{i} contract data:");
                    Console.Write("Date:  (DD/MM/YYYY): ");
                    DateTime date = DateTime.Parse(Console.ReadLine());
                    Console.WriteLine("ValuePerHours: ");
                    double valueperhour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                    Console.WriteLine("Duration: (Hours) ");
                    int          hours    = int.Parse(Console.ReadLine());
                    HourContract contract = new HourContract(date, valueperhour, hours);
                    worker.addContract(contract);
                } catch
                {
                    Console.WriteLine("Dados Inválidos!");
                }
            }

            Console.WriteLine();

            Console.WriteLine("Enter month and year to calculate income (MM/YYYY): ");
            string monthandyear = Console.ReadLine();
            int    month        = int.Parse(monthandyear.Substring(0, 2));
            int    year         = int.Parse(monthandyear.Substring(3));

            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + worker.Department.Name);
            Console.WriteLine("Icome for " + monthandyear + " : " + worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            Console.Write("Enter departament's name: ");
            string deptname = Console.ReadLine();

            Console.WriteLine("Enter worker data");
            Console.Write("Name: ");
            string workername = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base salary: ");
            double salary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Departament dept   = new Departament(deptname);
            Worker      worker = new Worker(workername, level, salary, dept);

            Console.WriteLine("How many contracts to this worker?");
            int times = int.Parse(Console.ReadLine());


            for (int i = 1; i <= times; i++)
            {
                Console.WriteLine();
                Console.WriteLine("Enter #" + i + " contract data:");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime data = DateTime.Parse(Console.ReadLine());
                Console.Write("Value per hour: ");
                double valueHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duration (hours):");
                int hours = int.Parse(Console.ReadLine());

                HourContract contract = new HourContract(data, valueHour, hours);

                worker.AddContract(contract);
            }

            Console.WriteLine();

            Console.Write("Enter month and year to calculate income (MM/YYYY): ");

            string vet   = Console.ReadLine();
            int    month = int.Parse(vet.Substring(0, 2));
            int    year  = int.Parse(vet.Substring(3));

            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Departament: " + worker.Departament.Name);
            Console.WriteLine("Income for: " + vet + ": " + worker.Income(year, month));
        }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            Console.Write("Digite o nome do departamento: ");
            string deptName = Console.ReadLine();

            Console.WriteLine("Enter Worker Data:");

            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junior/MidLevel/Senior/): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base Salary: ");
            double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Department dept   = new Department(deptName);
            Worker     worker = new Worker(name, level, baseSalary, dept);

            Console.WriteLine();
            Console.Write("Quantos contratos para esse trabalhador? ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine("Enter #" + i + " contract data: ");
                Console.Write("Date (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());

                Console.Write("Value per hour: ");
                double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

                Console.Write("Duration (Hours): ");
                int hours = int.Parse(Console.ReadLine());

                HourContract contract = new HourContract(date, valuePerHour, hours);
                worker.AddContract(contract);
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.Write("Entre com o mês e ano, para calcular o ganho (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2));
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine("Name: " + worker.Name);
            Console.WriteLine("Department: " + worker.Department.Name);
            Console.WriteLine("Income " + month + "/" + year + " : $ " + worker.Income(year, month).ToString("F2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            Console.WriteLine("Cadastro de empregados");
            Console.Write("Departamento: ");
            string       depart       = Console.ReadLine();
            Departamento departamento = new Departamento(depart);

            Console.Write("Nome: ");
            string nome = Console.ReadLine();

            Console.Write("Nível: ");
            WorkerLevel nivel = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Salário Base: ");
            double SalarioBase = double.Parse(Console.ReadLine());
            Worker trabalhador = new Worker(departamento, nome, nivel, SalarioBase);

            Console.WriteLine();
            Console.Write("Quantidade de contratos do empregado: ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.Write("Data do contrato: ");
                DateTime dataDoContrato = DateTime.Parse(Console.ReadLine());
                Console.Write("Valor por hora: ");
                double valorPorHora = double.Parse(Console.ReadLine());
                Console.Write("Quantidade de horas: ");
                int       quantidade = int.Parse(Console.ReadLine());
                Contratos contrato   = new Contratos(dataDoContrato, valorPorHora, quantidade);
                trabalhador.AcrescContratos(contrato);
            }

            Console.WriteLine();
            Console.WriteLine("Entre com o mês e o ano: ");
            string mesAno = Console.ReadLine();
            int    mes    = int.Parse(mesAno.Substring(0, 2));
            int    ano    = int.Parse(mesAno.Substring(3));

            Console.WriteLine("Dados do empregado:" + Environment.NewLine
                              + "Nome: " + nome
                              + Environment.NewLine
                              + "Departamento: " + departamento.Name
                              + Environment.NewLine
                              + "Nível: " + nivel
                              + Environment.NewLine
                              + "Saláro Base: " + SalarioBase
                              + Environment.NewLine
                              + "Total de salário: " + trabalhador.TotaldeSalario(ano, mes).ToString("C"));
        }
Exemplo n.º 30
0
        static void Main(string[] args)
        {
            Console.Write("Enter department's name: ");
            string depName = Console.ReadLine();

            Console.WriteLine("Enter worker data: ");
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Level (Junio/MidLevel/Senior): ");
            WorkerLevel level = Enum.Parse <WorkerLevel>(Console.ReadLine());

            Console.Write("Base salary: ");
            double salary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);


            Department dep    = new Department(depName);
            Worker     worker = new Worker(name, level, salary, dep);

            Console.Write("How many contracts to this worker: ");
            int contracts = int.Parse(Console.ReadLine());

            for (int i = 0; i < contracts; i++)
            {
                Console.WriteLine($"Enter #{i+1} contract data: ");
                Console.Write("Date: (DD/MM/YYYY): ");
                DateTime date = DateTime.Parse(Console.ReadLine());

                Console.Write("Value per hour: ");
                double valueHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

                Console.Write("Duration (hours): ");
                int hours = int.Parse(Console.ReadLine());

                HourContract contract = new HourContract(date, valueHour, hours);

                worker.AddContract(contract);//Adicionando o contrato que acabou de ser instanciado no trabalhador
            }

            Console.WriteLine();
            Console.Write("Enter month and year to calculate the income (MM/YYYY): ");
            string monthAndYear = Console.ReadLine();
            int    month        = int.Parse(monthAndYear.Substring(0, 2)); //estamos usando a funçao substring para recortar a string original na posição 0 até a 2 (0 é o indice como c fosse um array)
            int    year         = int.Parse(monthAndYear.Substring(3));

            Console.WriteLine($"Name: {worker.Name}");
            Console.WriteLine($"Department: {worker.Department.Name}");
            Console.WriteLine($"Income for {monthAndYear}: {worker.Income(year, month)}");
        }