static void Main(string[] args) { ApplicationUtilities.DisplayApplicationInformation(); // Here we call the Methods from the ApplicationUtilities Class ApplicationUtilities.DisplayDivider("Start Program"); Employee[] employeeList = new Employee[2]; //employeeList[0] = new Employee(); employeeList[0] = new Hourly("Hourly"); employeeList[1] = new Salaried("Salaried"); foreach (Employee emp in employeeList) { EmployeeInput.CollectEmployeeInformation(emp); if (emp is Hourly) { EmployeeInput.CollectHourlyInformation((Hourly)emp); } else if (emp is Salaried) { EmployeeInput.CollectSalaryInformation((Salaried)emp); } EmployeeOutput.DisplayEmployeeInformation(emp); ApplicationUtilities.PauseExecution(); } EmployeeOutput.DisplayNumberObject(); ApplicationUtilities.TerminateApplication(); }
private static void FillEmployeeArray(Employee[] employees) { int count = 0; do { int typeIn = InputUtilities.getIntegerInputValue("Employee Type: 1: for Salaried 2: for Hourly: "); if (typeIn == 1) { employees[count] = new Salaried(); ApplicationUtilities.DisplayDivider("Enter the Employee Information"); EmployeeInput.CollectSalariedInformation((Salaried)employees[count]); EmployeeOutput.DisplayEmployeeInformation((Salaried)employees[count]); ApplicationUtilities.DisplayDivider("Enter Next Employees information"); count++; //Increment to next Index } else if (typeIn == 2) { employees[count] = new Hourly(); ApplicationUtilities.DisplayDivider("\n============ Enter the Employee Information ================\n"); EmployeeInput.CollectHourlyInformation((Hourly)employees[count]); EmployeeOutput.DisplayEmployeeInformation((Hourly)employees[count]); ApplicationUtilities.DisplayDivider("------Enter Next Employees information----------"); count++; //Increment to next Index } else { Console.WriteLine("Thats not a valid Employee Type. Please try again"); } } while (count < employees.Length); }
public static void CollectSalariedInformation(Salaried theSalariedEmp) { theSalariedEmp.FirstName = InputUtilities.getStringInputValue("First Name"); theSalariedEmp.LastName = InputUtilities.getStringInputValue("Last Name"); theSalariedEmp.Gender = InputUtilities.getCharInputValue("Gender"); theSalariedEmp.Dependents = InputUtilities.getIntegerInputValue("Dependents"); theSalariedEmp.AnnualSalary = InputUtilities.getDoubleInputValue("Annual Salary"); theSalariedEmp.ManagementLevel = InputUtilities.getIntegerInputValue("Management Level"); theSalariedEmp.Benefit.HealthInsuranceCompany = InputUtilities.getStringInputValue("Health Insurance Company"); theSalariedEmp.Benefit.LifeInsuranceAmount = InputUtilities.getDoubleInputValue("Ammount of Life Insurance"); theSalariedEmp.Benefit.VacationDays = InputUtilities.getIntegerInputValue("Number of Vacation Days"); }
public static void instantiateSalariedEmployee(string t) { string[] values = t.Split('\n'); WriteLine("There are {0} elements in the values array\n", values.Length); Salaried s = null; s = new Salaried(values[0], values[1], values[2], Convert.ToBoolean(values[3]), Convert.ToInt32(values[4]), Convert.ToDouble(values[5]), Convert.ToDouble(values[6])); fillUpSalariedArrayList(s); }
//************************************* private static void newSalaryEmployee() { salariedArray[salariedCount] = new Salaried(); salariedArray[salariedCount].FirstName = generateFirstName(); salariedArray[salariedCount].MiddleInit = generateMiddleInit(); salariedArray[salariedCount].LastName = generateLastName(); salariedArray[salariedCount].IsUnion = generateUnionStatus(); salariedArray[salariedCount].EmpNum = generateEmployeeNumber(); salariedArray[salariedCount].WeekSalary = generateWeekSalary(); WriteLine(salariedArray[salariedCount]); salariedEmployee.Add(salariedArray[salariedCount]); salariedCount++; }
public void Main(string[] args) { //Remember to use .notation to call a method //Display Program Information ApplicationUtilities.DisplayApplicationInformation(); ApplicationUtilities.DisplayDivider("Start Program"); ApplicationUtilities.DisplayDivider("Prompt for Employee Information and creat first employee"); //array of employees Employee[] listEmployees = new Employee[2]; listEmployees[0] = new Hourly(); listEmployees[1] = new Salaried(); for (int i = 0; i < 2; i++) { if (listEmployees[i] is Hourly) { ApplicationUtilities.DisplayDivider("Get Hourly Information"); EmployeeInput.CollectEmployeeInformation(listEmployees[i]); EmployeeInput.CollectHourlyInformation((Hourly)listEmployees[i]); EmployeeOutput.DisplayEmployeeInformation((Hourly)listEmployees[i]); ApplicationUtilities.PauseExecution(); } else if (listEmployees[i] is Salaried) { ApplicationUtilities.DisplayDivider("Get Salaried Information"); EmployeeInput.CollectEmployeeInformation(listEmployees[i]); EmployeeInput.CollectSalariedInformation((Salaried)listEmployees[i]); EmployeeOutput.DisplayEmployeeInformation((Salaried)listEmployees[i]); ApplicationUtilities.PauseExecution(); } } EmployeeOutput.DisplayNumberObjects(); ApplicationUtilities.TerminateApplication(); }
public static void DisplayEmployeeInformation(Salaried theSalariedEmployee) { Console.WriteLine(theSalariedEmployee.ToString()); }
public static void CollectSalariedInformation(Salaried theEmployee) { //this method collects salaried employee information theEmployee.ManagementLevel = InputUtilities.getIntegerInputValue("Management Level"); theEmployee.AnnualSalary = InputUtilities.getDoubleInputValue("Annual Salary"); }
public static void fillUpSalariedArrayList(Salaried s) { s.CalculateEarnings(); salariedArray.Add(s); }
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(); }