THE CLASS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EmployeeLibrary
{
class Employee
{
private string Name = "";
private int num_of_worked_months = 0;
private double avg = 0;
public static int[] hours_per_month;
public string getName()
{
return Name;
}
public void setName(string value)
{
Name = value;
}
public int getNumber_Of_Worked_Months()
{
return num_of_worked_months;
}
public void setNumber_Of_Worked_Months(int value)
{
num_of_worked_months = value;
}
public double getAvg()
{
return avg;
}
public void setAvg(int value)
{
avg = value;
}
public int get_HPM(int month)
{
return hours_per_month[month];
}
public void set_HPM(int month, int value)
{
hours_per_month[month] = value;
}
}
}THE PROGRAM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FinalProject
{
class Program
{
public static void print_report(Employee[] emps, int num)
{
Console.WriteLine("The name \t the Avg");
for (int i = 0; i <= num; i++)
{
Console.WriteLine("the average is: emps.getName + emps.getAvg");
}
}
static void Main(string[] args)
{
int num_of_emps = 0;
string c = "";
int Number_Of_Worked_Months = 0;
Employee[] emps = new Employee[25];
if (num_of_emps > 0 && num_of_emps <= 24)
{
for (int i = 0; i <= num_of_emps; i++)
{
Console.Write("Welcome to our program");
for (int n = 0; n < emps.Length; n++)
emps[n] = new Employee();
Console.Write("Please enter employee name: ");
emps[n].setName(Console.ReadLine());
Console.Write("Please enter the number of months you have worked this year: ");
emps[n].setNumber_Of_Worked_Months(Int32.Parse(Console.ReadLine()));
Number_Of_Worked_Months = Int32.Parse(Console.ReadLine());
try
{
while (!num_of_worked_months > 12)
{
Console.WriteLine("Error inserting");
emps[n].setnumber_of_worked_months = Int32.Parse(Console.ReadLine());
}
for (int j = 0; j <= num_of_worked_months.Length - 1; j++)
{
Console.WriteLine("Enter the number of worked hores for the month num" + " " + (j + 1));
EmployeeLibrary.Employee.set_HPM = Int32.Parse(Console.ReadLine());
}
}
catch (Exception ex1)
{
Console.WriteLine(ex1.Message);
}
finally
{
Console.WriteLine("we are done");
}
int sort = 0;
for ( int b = 0; b <emps.Length; b++)
for (int t = 0; t < emps.Length; t++)
{
if (emps > emps[t])
{
sort = emps;
emps = emps[t];
emps[t] = sort;
}
}
for (int j = 0; j <= emps.num_of_worked_monthes - 1; j++)
{
temp += EmployeeLibrary.Employee.get_HPM(i);
}
emps.getAvg = (temp / emps.num_of_worked_monthes);
while (true)
{
Console.WriteLine("Is there any other employees, Press 'Y' for yes and 'N' if no: ");
c = Console.ReadLine();
switch (c)
{
case "y":
case "Y":
Console.WriteLine("Enter the number of the Employees");
num_of_emps = Int32.Parse(Console.ReadLine());
break;
case "n":
case "N":
print_report(emps, num_of_emps);
break;
}
print_report(emps, num_of_emps);
break;
}
if (c == "N" || c == "n")
{
break;
}
}
}
}
}
}لقد قمنا بإدخال بعض التعديلات على مشروع نهاية هذا الفصل الدراسي و هو عبارة عن عمل برنامج يوضح اسم الموظف و ساعات العمل و الشهور و ايجاد معدل ساعات العمل في كل شهر ل 25 موظف.
المشكله:
ان البرنامج لا يعمل لانه يظهر لنا بأن Employee الموجودة في ال Prpgram في البداية عند جملة الريبورت تظهر لنا أنها غير موجودة في البرنامج ولا نعلم كيف نجعل البرنامج يتعرف عليها ... و ايضا هناك هذا الاراي Employee[] emps = new Employee[25]; لا يظهر لنا باللون الاخضر ليدل على انه يستخدم الكلاس .. و واجهنا مشكلة اخرى في السلكشن سورتينج البرنامج يقول بأن emps > emps[t لايمكن تطبيقها في البرنامج ..
شاكرين لكم مساعداتكم ..


