Exemplo n.º 1
0
        public static void instantiateCommissionEmployee(string t)
        {
            string[] values = t.Split('\n');
            WriteLine("There are {0} elements in the values array\n", values.Length);
            Commission c = null;

            c = new Commission(values[0], values[1], values[2],
                               Convert.ToBoolean(values[3]),
                               Convert.ToInt32(values[4]),
                               Convert.ToDouble(values[5]),
                               Convert.ToDouble(values[6]),
                               Convert.ToDouble(values[7]));

            fillUpCommissionArrayList(c);
        }
Exemplo n.º 2
0
        //*************************************

        private static void newCommissionEmployee()
        {
            commissionArray[commissionCount] = new Commission();

            commissionArray[commissionCount].FirstName  = generateFirstName();
            commissionArray[commissionCount].MiddleInit = generateMiddleInit();
            commissionArray[commissionCount].LastName   = generateLastName();
            commissionArray[commissionCount].IsUnion    = generateUnionStatus();
            commissionArray[commissionCount].EmpNum     = generateEmployeeNumber();
            commissionArray[commissionCount].WeekSales  = generateWeekSales();
            commissionArray[commissionCount].CommRate   = generateCommRate();
            WriteLine(commissionArray[commissionCount]);
            commissionEmployee.Add(commissionArray[commissionCount]);

            ++commissionCount;
        }
Exemplo n.º 3
0
 public static void fillUpCommissionArrayList(Commission c)
 {
     c.CalculateEarnings();
     commisionArray.Add(c);
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {   //  Begin static void Main(string[] args)
            //  Call to Full-Arg Constructor

            ///HOURLY FLUFF///

            var goodNoOTEmployee0 = new Hourly();

            //fills goodNoOTEmployee0 with defaults

            //  Call to No-Arg Constructor
            var goodNoOTEmployee1 = new Hourly();

            //  Calls to associated setters
            goodNoOTEmployee1.FirstName   = "Jeffrey";
            goodNoOTEmployee1.MiddleInit  = "P";
            goodNoOTEmployee1.LastName    = "Scott";
            goodNoOTEmployee1.IsUnion     = false;
            goodNoOTEmployee1.EmpNum      = 1111;
            goodNoOTEmployee1.HoursWorked = 40.0;
            goodNoOTEmployee1.HourlyRate  = 25.0;
            goodNoOTEmployee1.CalculateEarnings();



            //  Call to No-Arg Constructor
            var goodOTEmployee = new Hourly();

            //  Calls to associated setters
            goodOTEmployee.FirstName   = "Mary";
            goodOTEmployee.MiddleInit  = "K";
            goodOTEmployee.LastName    = "Jones";
            goodOTEmployee.IsUnion     = true;
            goodOTEmployee.EmpNum      = 2222;
            goodOTEmployee.HoursWorked = 50.0;
            goodOTEmployee.HourlyRate  = 20.0;
            goodOTEmployee.CalculateEarnings();



            //  Call to No-Arg Constructor
            var badFNEmployee = new Hourly();

            //  Calls to associated setters
            badFNEmployee.FirstName   = "";
            badFNEmployee.MiddleInit  = "G";
            badFNEmployee.LastName    = "Wilson";
            badFNEmployee.IsUnion     = true;
            badFNEmployee.EmpNum      = 3333;
            badFNEmployee.HoursWorked = 45.0;
            badFNEmployee.HourlyRate  = 30.0;
            badFNEmployee.CalculateEarnings();



            //  Call to No-Arg Constructor
            var badMIEmployee = new Hourly();

            //  Calls to associated setters
            badMIEmployee.FirstName   = "Kiley";
            badMIEmployee.MiddleInit  = "";
            badMIEmployee.LastName    = "Fleming";
            badMIEmployee.IsUnion     = false;
            badMIEmployee.EmpNum      = 4444;
            badMIEmployee.HoursWorked = 40.0;
            badMIEmployee.HourlyRate  = 40.0;
            badMIEmployee.CalculateEarnings();



            //  Call to No-Arg Constructor
            var badLNEmployee = new Hourly();

            //  Calls to associated setters
            badLNEmployee.FirstName   = "John";
            badLNEmployee.MiddleInit  = "J";
            badLNEmployee.LastName    = "";
            badLNEmployee.IsUnion     = true;
            badLNEmployee.EmpNum      = 5555;
            badLNEmployee.HoursWorked = 10.0;
            badLNEmployee.HourlyRate  = 10.0;
            badLNEmployee.CalculateEarnings();



            //  Call to No-Arg Constructor
            var badENEmployee = new Hourly();

            //  Calls to associated setters
            badENEmployee.FirstName   = "Mark";
            badENEmployee.MiddleInit  = "B";
            badENEmployee.LastName    = "Bronson";
            badENEmployee.IsUnion     = false;
            badENEmployee.EmpNum      = 66666;
            badENEmployee.HoursWorked = 10.0;
            badENEmployee.HourlyRate  = 10.0;
            badENEmployee.CalculateEarnings();

            ///END HOURLY FLUFF///

            //  Hourly Exception Testing
            //OOR hours worked
            var badHWEmployee = new Hourly();

            try
            {
                //  Calls to associated setters
                badHWEmployee.FirstName   = "Jerry";
                badHWEmployee.MiddleInit  = "J";
                badHWEmployee.LastName    = "Granger";
                badHWEmployee.IsUnion     = false;
                badHWEmployee.EmpNum      = 8888;
                badHWEmployee.HoursWorked = -100.0;
                badHWEmployee.HourlyRate  = 10;
                badHWEmployee.CalculateEarnings();
            }
            catch (OutOfRangeHoursException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //OOR hourly rate
            var badHREmployee = new Hourly();

            try
            {
                //  Calls to associated setters
                badHREmployee.FirstName   = "Cari";
                badHREmployee.MiddleInit  = "J";
                badHREmployee.LastName    = "Granger";
                badHREmployee.IsUnion     = false;
                badHREmployee.EmpNum      = 8888;
                badHREmployee.HoursWorked = 50.0;
                badHREmployee.HourlyRate  = -10000.0;
                badHREmployee.CalculateEarnings();
            }
            catch (OutOfRangeHourlyRateException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //Salary Exception Testing
            var badWSalaryEmployee = new Salaried();

            try
            {
                badWSalaryEmployee.FirstName    = "John";
                badWSalaryEmployee.MiddleInit   = "M";
                badWSalaryEmployee.LastName     = "Stokes";
                badWSalaryEmployee.IsUnion      = false;
                badWSalaryEmployee.EmpNum       = 1111;
                badWSalaryEmployee.WeeklySalary = -10.0;
                badWSalaryEmployee.CalculateEarnings();
            }
            catch (OutOfRangeWeeklySalaryException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //PieceWorker Exception Testing
            //OOR pieces per hour
            var badPPHEmployee = new PieceWorker();

            try
            {
                badPPHEmployee.FirstName     = "Alyssa";
                badPPHEmployee.MiddleInit    = "T";
                badPPHEmployee.LastName      = "Stockton";
                badPPHEmployee.IsUnion       = false;
                badPPHEmployee.EmpNum        = 1111;
                badPPHEmployee.PiecesPerHour = -10;
                badPPHEmployee.PricePerPiece = .5;
                badPPHEmployee.CalculateEarnings();
            }
            catch (OutOfRangePiecesPerHourException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //OOR price per piece
            var badPPPEmployee = new PieceWorker();

            try
            {
                badPPPEmployee.FirstName     = "Dwayne";
                badPPPEmployee.MiddleInit    = "S";
                badPPPEmployee.LastName      = "Johnson";
                badPPPEmployee.IsUnion       = false;
                badPPPEmployee.EmpNum        = 2222;
                badPPPEmployee.PiecesPerHour = 50;
                badPPPEmployee.PricePerPiece = -10.0;
                badPPPEmployee.CalculateEarnings();
            }
            catch (OutOfRangePricePerPieceException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //Commission Exception Testing
            //OOR commission rate
            var badCREmployee = new Commission();

            try
            {
                badCREmployee.FirstName      = "Josh";
                badCREmployee.MiddleInit     = "T";
                badCREmployee.LastName       = "Lang";
                badCREmployee.IsUnion        = false;
                badCREmployee.EmpNum         = 1111;
                badCREmployee.CommissionRate = -10.0;
                badCREmployee.WeeklySales    = 5000;
                badCREmployee.CalculateEarnings();
            }
            catch (OutOfRangeCommissionRateException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //OOR weekly sales
            var badWSalesEmployee = new Commission();

            try
            {
                badWSalesEmployee.FirstName      = "Liza";
                badWSalesEmployee.MiddleInit     = "L";
                badWSalesEmployee.LastName       = "Koshy";
                badWSalesEmployee.IsUnion        = false;
                badWSalesEmployee.EmpNum         = 2222;
                badWSalesEmployee.CommissionRate = .20;
                badWSalesEmployee.WeeklySales    = -10;
                badWSalesEmployee.CalculateEarnings();
            }
            catch (OutOfRangeWeeklySalesException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }



            //  Call to No-Arg Commission Constructor
            var commEmployeeNoArg = new Commission();

            //  Call to getter
            //WriteLine("Employee 9:\n" + commEmployeeNoArg);

            //  Call to No-Arg Commission Constructor
            //var commEmployeeFullArg = new Commission("John", "J", "Jennings", false, 98766, 0.2, 2500);

            //  Call to getter
            //WriteLine("Employee 10:\n" + commEmployeeFullArg);

            //  Call to No-Arg Salaried Constructor
            var salEmployeeNoArg = new Salaried();

            //  Call to getter
            //WriteLine("Employee 11:\n" + salEmployeeNoArg);

            //  Call to No-Arg Commission Constructor
            //var salEmployeeFullArg = new Salaried("Helen", "H", "Hansen", false, 87654, 5500);

            //  Call to getter
            //WriteLine("Employee 12:\n" + salEmployeeFullArg);

            //  Call to No-Arg Salaried Constructor
            //var pwEmployeeNoArg = new PieceWorker();

            //  Call to getter
            // WriteLine("Employee 13:\n" + pwEmployeeNoArg);

            //  Call to No-Arg Commission Constructor
            //var pwEmployeeFullArg = new PieceWorker("Frank", "F", "Phillips", true, 76543, 58, 0.33);

            //  Call to getter
            //WriteLine("Employee 14:\n" + pwEmployeeFullArg);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //CREATE DEFAULT OBJECTS FOR EACH ARRAY LIST (5 each)

            //hourlyArray defaults
            //fluff
            hourlyArray.Add(goodNoOTEmployee0);
            hourlyArray.Add(goodNoOTEmployee1);
            hourlyArray.Add(badENEmployee);
            hourlyArray.Add(badFNEmployee);

            //exceptions
            hourlyArray.Add(badHREmployee);
            hourlyArray.Add(badHWEmployee);

            //salariedArray defaults
            salariedArray.Add(badWSalaryEmployee);
            salariedArray.Add(salEmployeeNoArg);

            //pieceWorkerArray defaults
            pieceWorkerArray.Add(badPPHEmployee);
            pieceWorkerArray.Add(badPPPEmployee);

            //commissionArray defaults
            commisionArray.Add(badCREmployee);
            commisionArray.Add(badWSalesEmployee);
            commisionArray.Add(commEmployeeNoArg);


            presentMenu();
        }