private void DisplayData(EmployeeID id) { object empobj = employees[id]; if (empobj != null) { EmployeeData employee = (EmployeeData)empobj; Console.WriteLine("Employee: " + employee.ToString()); } else { Console.WriteLine("Employee not found: ID = " + id); } }
public override bool Equals(object obj) { EmployeeID rhs = obj as EmployeeID; if (rhs == null) { return(false); } if (prefix == rhs.prefix && number == rhs.number) { return(true); } return(false); }
public EmployeeData(EmployeeID id, string name, decimal salary) { this.id = id; this.name = name; this.salary = salary; }
private void DisplayData(EmployeeID id) { object empobj = employees[id]; if (empobj != null) { EmployeeData employee = (EmployeeData)empobj; Console.WriteLine("Employee: " + employee.ToString()); } else Console.WriteLine("Employee not found: ID = " + id); }
public void Run() { EmployeeID idMortimer = new EmployeeID("B001"); EmployeeData mortimer = new EmployeeData(idMortimer, "Mortimer", 100000.00M); EmployeeID idArabel = new EmployeeID("W234"); EmployeeData arabel= new EmployeeData(idArabel, "Arabel Jones", 10000.00M); employees.Add(idMortimer, mortimer); employees.Add(idArabel, arabel); while (true) { try { Console.Write("Enter employee ID (format:A999, X to exit)> "); string userInput = Console.ReadLine(); userInput = userInput.ToUpper(); if (userInput == "X") return; EmployeeID id = new EmployeeID(userInput); DisplayData(id); } catch (Exception e) { Console.WriteLine("Exception occurred. Did you use the correct format for the employee ID?"); Console.WriteLine(e.Message); Console.WriteLine(); } Console.WriteLine(); } }