Пример #1
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>
 public SalariedEmployee(int employeeId, string name, 
     string username, Location location, string phoneNumber, 
     int payGrade)
     : base(employeeId, name, username,location, phoneNumber)
 {
     if (payGrade >= 0 && payGrade <= maxGrade)
     {
         this.payGrade = payGrade;
     }
 }
Пример #2
0
        static void ArraysDemo()
        {
            int[] myIntegers = new int[10];
            myIntegers[0] = 42;

            char[] myChars = { 'H', 'e', 'l', 'l', 'o' };

            for (int i = 0; i < myIntegers.Length; i++)
            {
                myIntegers[i] = i;
            }

            Console.Write("Array contents: ");
            foreach (int myInt in myIntegers)
            {
                Console.Write("{0} ", myInt);
            }

            Console.Write("\n");

            Location loc = new Location();

            Employee[] employees = new Employee[10];
            HourlyPaidEmployee emp1 = new HourlyPaidEmployee(1, "Michael",
                "michael", loc, "1234");
            SalariedEmployee emp2 = new SalariedEmployee(2, "Susan", "susan",
                loc, "5678", 6);
            employees[0] = emp1;
            employees[1] = emp2;

            SalariedEmployee semp = (SalariedEmployee)employees[1];
            int grade = semp.PayGrade;

            int[,] numbers = new int[3, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
            string[,] siblings = new string[2, 2] {
                { "Mike", "Amy" },
                { "Mary", "Albert" }
                };

            Console.ReadLine();
        }
Пример #3
0
 //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)
 {
 }
Пример #4
0
        static void SimpleListsDemo()
        {
            Location loc = new Location();

            ISimpleList employees = new SimpleArrayList();
            //ISimpleList employees = new SimpleLinkedList();
            //SimpleGenericArrayList<Employee> employees = new SimpleGenericArrayList<Employee>();

            HourlyPaidEmployee emp1 = new HourlyPaidEmployee(1, "Michael",
                "michael", loc, "1234");
            SalariedEmployee emp2 = new SalariedEmployee(2, "Susan", "susan",
                loc, "5678", 6);

            employees.Add(emp1);
            employees.Add(emp2);

            SalariedEmployee semp = (SalariedEmployee)employees.Get(1);
            int grade = semp.PayGrade;

            Employee emp = (Employee) employees.Get(0);   // need to cast
            emp.Move(new Location());

            Employee target = new SalariedEmployee(1, null, null, null, null, 0);
            employees.Remove(target);

            // test IEnumerable version - remove for student download, will do in lab
            //SimpleEnumerableArrayList seal = new SimpleEnumerableArrayList();
            //seal.Add("Plato");
            //seal.Add("McDowell");
            //seal.Add("Neal");
            //seal.Add("Shedden");
            //seal.Add("Kane");

            //foreach (String s in seal)
            //{
            //    Console.WriteLine(s);
            //}

            Console.ReadLine();
        }