rendered paste bodyusing System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace PayRoll_Reader
{
static class Reader
{
public static Employee[] emps = new Employee[0];
public static void ReadEmployees()
{
int count = 0;
StreamReader read = new StreamReader("payroll.dat");
while(!(read.EndOfStream))
{
string LineInfo;
LineInfo = read.ReadLine();
if(!(read.EndOfStream))
{
Employee[] temp = new Employee[Employee.empCount + 1];
for (int i = 0; i < emps.Length; i++)
{
temp[i] = emps[i];
}
Employee.empCount += 1;
emps = new Employee[Employee.empCount];
for (int i = 0; i < emps.Length; i++)
{
emps[i] = temp[i];
}
emps[emps.Length - 1] = new Employee();
emps[emps.Length - 1].BranchNum = int.Parse(ParseString(LineInfo,ref count));
emps[emps.Length - 1].DivNum = int.Parse(ParseString(LineInfo, ref count));
emps[emps.Length - 1].DepartNum = int.Parse(ParseString(LineInfo, ref count));
emps[emps.Length - 1].EmpFName = ParseString(LineInfo, ref count);
emps[emps.Length - 1].EmpLName = ParseString(LineInfo, ref count);
emps[emps.Length - 1].HoursWork = int.Parse(ParseString(LineInfo, ref count));
emps[emps.Length - 1].PayRate = double.Parse(ParseString(LineInfo, ref count));
count = 0;
}
}
read.Close();
for (int i = 0; i < emps.Length; i++)
{
emps[i].CalcGrossPay();
}
}
static string ParseString(string ToParse, ref int count)
{
string temp = "";
int debug = ToParse.Length;
while (ToParse.Length -1 != count && ToParse[count] != ' ')
{
temp += ToParse[count];
count++;
}
count++;
return temp;
}
}
}