Пример #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();
        }
Пример #2
0
 /// <summary>
 /// default constructor
 /// </summary>
 public Employee()
 {
     this.employeeId = -1;
     this.name = "default";
     this.username = "******";
     this.currentLocation = null;
     this.phoneNumber = "0000";
 }
Пример #3
0
 //CONSTRUCTORS
 /// <summary>
 /// constructor for Employee 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 Employee(int employeeId, string name, string username,
     Location location, string phoneNumber)
 {
     this.employeeId = employeeId;
     this.name = name;
     this.username = username;
     this.currentLocation = location;
     this.phoneNumber = phoneNumber;
 }
Пример #4
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;
     }
 }
Пример #5
0
 //METHODS
 /// <summary>
 /// Move to a new location
 /// </summary>
 /// <param name="newLocation">the new location</param>
 public void Move(Location newLocation)
 {
     currentLocation = newLocation;
 }
Пример #6
0
 // METHODS
 /// <summary>
 /// Move to a new location
 /// </summary>
 /// <param name="newLocation">the new location</param>
 public void Move(Location newLocation)
 {
     employee.Move(newLocation);
 }
Пример #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);
        }