Beispiel #1
0
        static void Main(string[] args)
        {
            // create objects
            Location loc = new Location { Description = "Head Office", City = "Glasgow" };
            HourlyPaidEmployee emp1 = new HourlyPaidEmployee(1, "Michael",
                "michael", loc, "1234");
            SalariedEmployee emp2 = new SalariedEmployee(2, "Susan", "susan",
                loc, "5678", 6);
            Employee emp3 = new HourlyPaidEmployee(3, "Ahmad", "ahmad",
                loc, "4321");
            Department dep = new Department();
            dep.AddEmployee(emp1);
            dep.AddEmployee(emp2);
            dep.AddEmployee(emp3);
            DatabaseTimeSheet dts = new DatabaseTimeSheet(@"mydb");

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

            Object o = new HourlyPaidEmployee();
            SalariedEmployee semp = o as SalariedEmployee;

            // wait for key press before ending
            Console.ReadLine();
        }
Beispiel #2
0
 /// <summary>
 /// default constructor
 /// </summary>
 public Employee()
 {
     this.employeeId = -1;
     this.name = "default";
     this.username = "******";
     this.currentLocation = null;
     this.phoneNumber = "0000";
 }
Beispiel #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;
 }
Beispiel #4
0
 //METHODS
 /// <summary>
 /// Move to a new location
 /// </summary>
 /// <param name="newLocation">the new location</param>
 public virtual void Move(Location newLocation)
 {
     currentLocation = newLocation;
 }
 //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)
     : base(employeeId, name, username,location, phoneNumber)
 {
 }