Ejemplo n.º 1
0
 public Worker(string name, WorkerLvel level, double baseSalary, Depertment depertment)
 {
     Name       = name;
     Level      = level;
     BaseSalary = baseSalary;
     Depertment = depertment;
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.Write("Enter department's name: ");
            string departName = Console.ReadLine();

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

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

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

            Depertment depertment = new Depertment(departName);
            Worker     worker     = new Worker(name, level, baseSalary, depertment);

            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("Valeu per hour: ");
                double valeuPerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Duration (hours): ");
                int duration = int.Parse(Console.ReadLine());
                Console.WriteLine();
                HourContract contract = new HourContract(date, valeuPerHour, duration);
                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("Depertment: " + worker.Depertment.Name);
            Console.WriteLine("Income for " + monthAndYear + ": " + worker.Income(year, month).ToString("f2", CultureInfo.InvariantCulture));
        }