Esempio n. 1
0
        static void Main()
        {
            var employees = new Dictionary<EmployeeId, Employee>(31);

            var idKyle = new EmployeeId("T3755");
            var kyle = new Employee(idKyle, "Kyle Bush", 5443890.00m);
            employees.Add(idKyle, kyle);
            Console.WriteLine(kyle);

            var idCarl = new EmployeeId("F3547");
            var carl = new Employee(idCarl, "Carl Edwards", 5597120.00m);
            employees.Add(idCarl, carl);
            Console.WriteLine(carl);

            var idJimmie = new EmployeeId("C3386");
            var jimmie = new Employee(idJimmie, "Jimmie Johnson", 5024710.00m);
            employees.Add(idJimmie, jimmie);
            Console.WriteLine(jimmie);

            var idDale = new EmployeeId("C3323");
            var dale = new Employee(idDale, "Dale Earnhardt Jr.", 3522740.00m);
            employees[idDale] = dale;
            Console.WriteLine(dale);

            var idJeff = new EmployeeId("C3234");
            var jeff = new Employee(idJeff, "Jeff Burton", 3879540.00m);
            employees[idJeff] = jeff;
            Console.WriteLine(jeff);

            while (true)
            {
                Console.Write("Enter employee id (X to exit)> ");
                var userInput = Console.ReadLine();
                userInput = userInput.ToUpper();
                if (userInput == "X") break;

                EmployeeId id;
                try
                {
                    id = new EmployeeId(userInput);

                    Employee employee;
                    if (!employees.TryGetValue(id, out employee))
                    {
                        Console.WriteLine("Employee with id {0} does not exist", id);
                    }
                    else
                    {
                        Console.WriteLine(employee);
                    }
                }
                catch (EmployeeIdException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Esempio n. 2
0
        static void Main()
        {
            var employees = new Dictionary<EmployeeId, Employee>(31);

              var idTony = new EmployeeId("C3755");
              var tony = new Employee(idTony, "Tony Stewart", 379025.00m);
              employees.Add(idTony, tony);
              Console.WriteLine(tony);

              var idCarl = new EmployeeId("F3547");
              var carl = new Employee(idCarl, "Carl Edwards", 403466.00m);
              employees.Add(idCarl, carl);
              Console.WriteLine(carl);

              var idKevin = new EmployeeId("C3386");
              var kevin = new Employee(idKevin, "Kevin Harwick", 415261.00m);
              employees.Add(idKevin, kevin);
              Console.WriteLine(kevin);

              var idMatt = new EmployeeId("F3323");
              var matt = new Employee(idMatt, "Matt Kenseth", 1589390.00m);
              employees[idMatt] = matt;
              Console.WriteLine(matt);

              var idBrad = new EmployeeId("D3234");
              var brad = new Employee(idBrad, "Brad Keselowski", 322295.00m);
              employees[idBrad] = brad;
              Console.WriteLine(brad);

              while (true)
              {
            Console.Write("Enter employee id (X to exit)> ");
            var userInput = Console.ReadLine();
            userInput = userInput.ToUpper();
            if (userInput == "X") break;

            EmployeeId id;
            try
            {
              id = new EmployeeId(userInput);

              Employee employee;
              if (!employees.TryGetValue(id, out employee))
              {
            Console.WriteLine("Employee with id {0} does not exist", id);
              }
              else
              {
            Console.WriteLine(employee);
              }
            }
            catch (EmployeeIdException ex)
            {
              Console.WriteLine(ex.Message);
            }
              }
        }