Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Basic C# were you design a form. Pictures of the code and pictures showing the p

ID: 3770932 • Letter: B

Question

Basic C# were you design a form. Pictures of the code and pictures showing the programming running would be much appreciated.

Create an Employee class that has properties for the following data:

Employee name

Employee number

Next, create a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have properties to hold the following data:

Shift number (an integer such as 1, 2, or 3)

Hourly pay rate

The workday is divided into two shifts: day and night. The Shift property will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2.

Create an application that creates an object of the ProductionWorker class and let's the user enter data for each of the objects properties. Retrieve the objects properties and display their values.

Explanation / Answer

I have done this(Hope that this could help you)

First of all I have made Employee class

Then I have made the class ProductionWorker that inherit the two properties from Employee

I made a public enum so the code it's more readable

In main you can simply create an istance of ProductionWorker and then you can do something like that

EDIT 1

Of course you can assign all numbers that you want in an Enum object

But it's not recommended in these case(in other yes: for example if you want use an enum as Flag). It's more used check the enum and then do the calculations in a variable for example

EDIT 2 This is the complete enum object

EDIT 3 If you want store more then one productionWorker you can do something like that

1)First off all declare a global List like that

2)Add a ProductionWorker class to the list(for example)

This is a simple implementation if you want do it better you must check if EmployeeNumber already exist. You can do it in two ways

1)Using a foreach

bool find = false; foreach(ProductionWorker w in pw) if(v.EmployeeNumber.Equals(EmployeeNumberInput)) { find = true; break; }

2)Or you can use System.Linq nowadays it's a much more idiomatic approach

(I'd also suggest following the .NET naming conventions.)

var temp=pw.Find(item=> item.EmployeeNumber.Equals(EmployeeNumberInput)) if(temp!=null) //ID already exist show an error else{ //Add a new object to list }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote