THis assignment builds off previous assignments made in Visual Studios 2019. It is due by 11.59 pm this Saturday.. I have given Sarah everything you need, Thank you
Course Project DeVry University College of Engineering and Information Sciences Screenshot of program running: Form code (only the code for the form, not program.cs): Course Project DeVry University College of Engineering and Information Sciences Course Number: CEIS209 Background This course project is designed to help you practice using your skills. Each week, you will learn important concepts. Then, you will apply these concepts to build an amazing course project over the next seven weeks. What’s more, this project will have a Graphical User Interface (GUI) instead of using the console. This course project has two parts. For the first couple of weeks, you will be create a basic GUI and learn how to work with GUI controls while practicing basic programming concepts. After that, you will create an object oriented project. Part 2: Scenario You have been hired as a consultant to create a basic Payroll System for a small business. The business wants to keep track of basic employee information and print paychecks for the employees every two weeks. Your client has some basic functionality in mind, such as the ability to add and remove employees, display basic employee information, and print paychecks. Maintenance is key! You realize that Object-Oriented programming will provide the most efficient application that is easy to maintain and update as needed. Let’s get started! Week 7: Final Project – Composition and Inheritance Objectives 1. Integrate Employee class 2. Data hiding Introduction So far, your application can keep track of basic employee information. You can add and remove employees. The basic information is displayed efficiently by your listbox. However, the company offers a benefit to their employees. The company wants the application to track these benefits since the benefits are considered part of the basic employee information. Since we are using object-oriented programming techniques, it will be easy to “attach” the benefits to the employees. The employee object will be contain the benefits object. In OOP speak, the Employee object is composed of a Benefits object. Also, we cannot write paychecks because we do not know how to pay the employees! Since we only have one class, do the pay the employees a base salary or do we pay them an hourly rate or do pay them a consulting fee? It is impossible to pay the variety of employees using one single class. Therefore it is going to be a lot of work to write the Salary class and the Hourly class and any other employee classes that we need since we have to rewrite every single attribute and method. Right? NO! We can use Inheritance! With Inheritance, we create a base class and then extend this base class into subclasses. In other words, we create a Parent class and then create Child classes that inherit the attributes and behaviors from the Parent class. This way, we only have to write the attributes and behaviors that are unique to that Child class! Since we are using object-oriented programming techniques, it will be easy to “extend” the base class into many different subclasses. We will only need to code the differences in the Child classes. Once we set up the Inheritance relationship, we can set up our ListBox to automatically show the Child properties by overriding the ToString( ) method. Inheritance is going to save us a massive amount of work! Steps 1. Open your course project solution from last week. Previously, we created an Employee class to encapsulate the employee information. This week, we are going to create a Benefits class that encapsulates the important benefits information that we want to track for each employee. Now, here is the most important part. Each Employee object must contain a Benefits object. This way, when we have an Employee object open, we can simply open that Employee object’s Benefits object. In OOP speak, this is called “Composition”. The Employee object is composed of a Benefits object. Think of it like this. If you have a Person object, you can use the dot operator to get the person’s Wallet object. The Person “has a” Wallet, or the Person “contains” a Wallet. Once the Wallet object is open, we can check important information like driver’s license number or amount of cash the person has in their wallet. If we use Composition, we will create an attribute in our Employee class that is a Benefits object. The Employee object will be composed of a Benefits object. This way, we can open our Employee object. Then, we can use the dot operator on the Employee object to get the Benefits object that it contains. Create a Benefits class. Then, create an attribute in the Employee class so the Employee class contains a Benefits object. Here is the UML class diagram for the Benefits class showing the Composition relationship between the Employee class and the Benefits class. 2. Since we changed the structure of our Employee class, we need to update project to accommodate the updated Employee objects. a. Change your Input form to get the Benefits information as well b. Update the AddButton_Click event method to get the additional information and create Employee objects using Composition. private void AddButton_Click(object sender, EventArgs e) { // add item to the employee listbox InputForm frmInput = new InputForm(); using (frmInput) { DialogResult result = frmInput.ShowDialog(); // see if input form was cancelled if (result == DialogResult.Cancel) return; // end method since user cancelled the input // get user's input and create an Employee object string fName = frmInput.FirstNameTextBox.Text; string lName = frmInput.LastNameTextBox.Text; string ssn = frmInput.SSNTextBox.Text; string date = frmInput.HireDateTextBox.Text; DateTime hireDate = DateTime.Parse(date); string healthIns = frmInput.HealthInsTextBox.Text; double lifeIns = Double.Parse( frmInput.LifeInsTextBox.Text ); int vacation = Int32.Parse( frmInput.VacationTextBox.Text ); Benefits benefits = new Benefits(healthIns, lifeIns, vacation); Employee emp = new Employee(fName, lName, ssn, hireDate, benefits); // add the Employee object to the employees listbox EmployeesListBox.Items.Add(emp); // write all Employee objects to the file WriteEmpsToFile(); } } c. Update the WriteEmpsToFile( ) method to write all of the Employee information, including the Benefits information: private void WriteEmpsToFile() { // write all Employee objects to the file string fileName = "Employees.csv"; StreamWriter sw = new StreamWriter(fileName); for (int i = 0; i < employeeslistbox.items.count;="" i++)="" {="" employee="" temp="(Employee)EmployeesListBox.Items[i];" sw.writeline(temp.firstname="" +="" ','="" +="" temp.lastname="" +="" ','="" +="" temp.ssn="" +="" ','="" +="" temp.hiredate.toshortdatestring()="" +="" ','="" +="" temp.benefitspackage.healthinsurance="" +="" ','="" +="" temp.benefitspackage.lifeinsurance="" +="" ','="" +="" temp.benefitspackage.vacation);="" }="" sw.close();="" tell="" user="" that="" the="" records="" were="" written="" to="" the="" file="" messagebox.show("employees="" were="" written="" to="" the="" file.");="" }="" d.="" update="" the="" readempsfromfile(="" )="" method="" to="" read="" all="" of="" the="" employee="" information,="" including="" the="" benefits="" information:="" private="" void="" readempsfromfile()="" {="" read="" all="" employee="" objects="" from="" the="" file="" string="" filename="Employees.csv" ;="" streamreader="" sr="new" streamreader(filename);="" using="" (sr)="" {="" while="" (sr.peek()=""> -1) { // read the line and break it into parts based on commas string line = sr.ReadLine(); string[] parts = line.Split(','); string fName = parts[0]; string lName = parts[1]; string ssn = parts[2]; DateTime hireDate = DateTime.Parse(parts[3]); string healthIns = parts[4]; double lifeIns = Double.Parse(parts[5]); int vacation = Int32.Parse(parts[6]); // create the Employee object and add it to the listbox Benefits benefits = new Benefits(healthIns, lifeIns, vacation); Employee emp = new Employee(fName, lName, ssn,