Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // create objects
            Location loc = new Location { Description = "Head Office", City = "Glasgow" };
            HourlyPaidEmployee hpemp1 = new HourlyPaidEmployee(1, "Michael", "michael", loc, "1234");
            Employee emp2 = new Employee(2, "Susan", "susan", loc, "5678");
            SalariedEmployee semp2 = new SalariedEmployee(emp2, 6);
            DatabaseTimeSheet dts = new DatabaseTimeSheet(@"mydb");

            // send messages (call methods)
            Console.WriteLine("Email address for {0}: {1}", hpemp1.Name, hpemp1.Email());
            hpemp1.RecordTime(dts, 5, PayRate.Weekend);
            Console.WriteLine("Email address for {0}: {1}", semp2.Name, emp2.Email());
            int newGrade = semp2.PayIncrement();
            Console.WriteLine("New grade for {0}: {1}", semp2.Name, newGrade);

            // change Susan's role to an HourlyPaidEmployee
            HourlyPaidEmployee hpemp2 = new HourlyPaidEmployee(emp2);
            semp2 = null;
            hpemp2.RecordTime(dts, 5, PayRate.Weekend);
            Console.WriteLine("Email address for {0}: {1}", hpemp2.Name, hpemp2.Email());

            // wait for key press before ending
            Console.ReadLine();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// constructor for SalariedEmployee objects
 /// </summary>
 /// <param name="employee">the employee</param>
 /// <param name="payGrade">the employee's pay grade</param>
 public SalariedEmployee(Employee employee, int payGrade)
 {
     this.employee = employee;
     if (payGrade >= 0 && payGrade <= maxGrade)
     {
         this.payGrade = payGrade;
     }
 }
Ejemplo n.º 3
0
 //CONSTRUCTORS
 /// <summary>
 /// constructor for SalariedEmployee objects
 /// </summary>
 /// <param name="employeeId">the employee's id number</param>
 /// <param name="name">the employee's name</param>
 /// <param name="username">the employee's username</param>
 /// <param name="location">the employee's initila location</param>
 /// <param name="phoneNumber">the employee's phone number</param>
 /// <param name="phoneNumber">the employee's pay grade</param>
 public SalariedEmployee(int employeeId, string name, 
     string username, Location location, string phoneNumber, int payGrade)
 {
     this.employee = new Employee(employeeId, name, username, location, phoneNumber);
     if (payGrade >= 0 && payGrade <= maxGrade)
     {
         this.payGrade = payGrade;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// default constructor
 /// </summary>
 public SalariedEmployee()
 {
     this.employee = null;
     this.payGrade = 0;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// default constructor
 /// </summary>
 public HourlyPaidEmployee()
 {
     this.employee = null;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// constructor for SalariedEmployee objects
 /// </summary>
 /// <param name="employee">the employee</param>
 public HourlyPaidEmployee(Employee employee)
 {
     this.employee = employee;
 }
Ejemplo n.º 7
0
        private Employee employee; // composition

        #endregion Fields

        #region Constructors

        //CONSTRUCTORS
        /// <summary>
        /// constructor for HourlyPaidEmployee objects
        /// </summary>
        /// <param name="employeeId">the employee's id number</param>
        /// <param name="name">the employee's name</param>
        /// <param name="username">the employee's username</param>
        /// <param name="location">the employee's initila location</param>
        /// <param name="phoneNumber">the employee's phone number</param>
        public HourlyPaidEmployee(int employeeId, string name, 
            string username, Location location, string phoneNumber)
        {
            this.employee = new Employee(employeeId, name, username, location, phoneNumber);
        }