Beispiel #1
0
        private Employee CreateStudentProgrammer(double startingWage)
        {
            Console.Write("Enter the student's name:");
            string name = Console.ReadLine();
            Employee cheapWorker;
            // Create the employee object by calling the Greedy constructor
            cheapWorker = new Employee(name, 20, startingWage, DateTime.Today, "780.555.2003");

            return cheapWorker;
        }
Beispiel #2
0
        private void CompareSalary(Employee personA, Employee personB)
        {
            double salaryDifference = personA.Salary - personB.Salary;
            // get the absolute value
            salaryDifference = Math.Abs(salaryDifference);

            string paidTheMost;
            if (personA.Salary > personB.Salary)
                paidTheMost = personA.Name;
            else
                paidTheMost = personB.Name;

            Console.WriteLine(paidTheMost + " is paid $" + salaryDifference + " more than the other guy.");
        }
Beispiel #3
0
 private Employee CreateHeadProgrammer()
 {
     // Instantiate (create) an object using an Initializer List
     Employee allan = new Employee()
     {
         Name = "Allan",
         Age = 27,
         Salary = 75000,
         StartingDate = new DateTime(2010, 10, 28),
         PhoneNumber = "780.555.1212"
     };
     // return the data
     return allan;
 }
Beispiel #4
0
 private void ApplyRaise(Employee someone)
 {
     // Ask user for a raise amount, between 2 and 10 inclusive
     Console.Write("Enter raise amount (2-10): ");
     double raise = double.Parse(Console.ReadLine());
     while (raise < 2 || raise > 10)
     {
         Console.WriteLine("Not a valid number.");
         Console.Write("Enter raise amount (2-10): ");
         raise = double.Parse(Console.ReadLine());
     }
     // BUG #1: forgot to adjust for being a percentage...
     raise = raise / 100;
     // change the employee's salary
     someone.AssignBonus(raise);
 }