示例#1
0
        static void Main(string[] args)
        {
            // create objects
            Location loc = new Location { Description = "Head Office", City = "Glasgow" };
            Employee emp1 = new Employee("Michael", "michael", loc, "1234");
            Employee emp2 = new Employee("Susan", "susan", loc, "4321");
            Employee emp3 = new Employee();
            TimeSheet ts = new TimeSheet();

            // use properties
            string uname = emp2.Username;
            Console.WriteLine("Email address for Susan is {0}", emp2.Email);
            emp2.PhoneNumber = "5678";
            TimeSheet.MaxEntries = 100;

            // send messages (call methods)
            emp1.RecordOvertime(ts, 5, true);    // note that as a result of this, emp1 sends a message to ts
            int overTime = emp1.TotalOvertime(ts);
            Console.WriteLine("total hours for Michael: {0}", overTime);
            TimeSheet.IncreaseMaxEntriesBy(50);

            // wait for key press before ending
            Console.ReadLine();

            double angle = Math.PI;
            double result = Math.Sin(angle);
        }
示例#2
0
 // end RecordOvertime
 /// <summary>
 /// gets the total overtime recorded for this employee in the specified time sheet
 /// </summary>
 /// <param name="timeSheet">the time sheet</param>
 /// <returns>the total hours recorded</returns>
 public int TotalOvertime(TimeSheet timeSheet)
 {
     // get total overtime hours recorded in the specified timesheet
     // for this employee - we will fill in the details of this later,
     // just return an arbitrary value for now
     return 100;
 }
示例#3
0
 // end Move
 /// <summary>
 /// records an overtime entry in a specified time sheet
 /// </summary>
 /// <param name="timeSheet">the time sheet</param>
 /// <param name="hours">the number of hours to record</param>
 /// <param name="isWeekend">true if overtime worked at weekend - 
 /// weekend hours count as double time</param>
 public void RecordOvertime(TimeSheet timeSheet, int hours, 
     bool isWeekend)
 {
     // send message to time sheet object to ask it to
     // record information
     if (isWeekend)
     {
         timeSheet.AddEntry(name, hours * 2);
     }
     else
     {
         timeSheet.AddEntry(name, hours);
     }
 }