void printDetails(hseEmployee emp) { list_empList.Items.Add(emp.EmpName); list_empDetails.Items.Add("Emp Name: " + emp.EmpName); list_empDetails.Items.Add("Emp Number: " + emp.EmpNumber); list_empDetails.Items.Add("Emp Type: " + emp.EmpType); list_empDetails.Items.Add("Emp Yrs Service: " + emp.EmpYrsService); list_empDetails.Items.Add("Emp Salary: €" + emp.EmpSalary); if (emp is Doctor) { list_empDetails.Items.Add("I can prescribe medicine!"); } list_empDetails.Items.Add("\n"); }
private void btn_createEmployee_Click(object sender, EventArgs e) { if (txt_empName.Text == "") { hseEmployee employee1 = new hseEmployee(); printDetails(employee1); } else { hseEmployee employee2 = new hseEmployee(txt_empName.Text, txt_empType.Text, int.Parse(txt_empYrsOfService.Text), Double.Parse(txt_empSalary.Text)); printDetails(employee2); } Doctor MyDoctor = new Doctor("Mario", "Doctor", 2, 110000); printDetails(MyDoctor); }
private void btn_generateEmployees_Click(object sender, EventArgs e) { for (int i = 0; i <= 10; i++) { String[] nameArray = { "Carl", "Jenny", "Sean", "Smith", "Mary" }; String randName = nameArray[rand.Next(0, 5)]; String[] jobArray = { "Standard", "Porter", "Doctor" }; String randJob = jobArray[rand.Next(0, 3)]; int randYrsOfService = rand.Next(1, 10); double randSalary = rand.Next(30000, 150000); if (String.Equals(randJob, "Doctor")) { Doctor ADoctor = new Doctor(randName, randJob, randYrsOfService, randSalary); printDetails(ADoctor); } else { hseEmployee AnEmployee = new hseEmployee(randName, randJob, randYrsOfService, randSalary); printDetails(AnEmployee); } } }