I'm trying to create a system that allows you to create a hospital ward and then add patients with personal details to each ward. The intention is being able to read all information from a single text/csv file.
I currently have the code to create patients and add their details but creating a ward and assigning patients to the ward is beyond my grasp. My lecturer suggested using an array of Patients as a property in the Ward class but its beyond my comprehension at the moment. A typical Patient would be written in my textfile as ''JoeBloggs,28,03/03/1989,8'' And the below code sorts the attributes etc.
Here is my current code to create patients:
private void btnLoad_Click(object sender, RoutedEventArgs e)
{
//read files from file
string[] patientList = File.ReadAllLines("MyList.txt");
string[] patientArray = new string[4];
string patientLong, name;
Patient patient;
int age, blood;
DateTime dob;
.
for (int i = 0; i < patientList.Length; i++)
{
patientLong = patientList[i];//one long string with commas eg johnmurphy,22,12/9/1998,6
patientArray = patientLong.Split(',');//split array according to comma
name = patientArray[0];
age = Convert.ToInt32(patientArray[1]);
dob = DateTime.Parse(patientArray[2]);
blood = Convert.ToInt32(patientArray[3]);
patient = new Patient(name,age,dob,blood);
bookList.Add(patient);
}
// lbxExpenses.ItemsSource = null;
lstPatients.ItemsSource = patientList;
}
And class Ward
class Ward
{
public string Name { get; set; }
public Patient [] Patient { get; set; }//array of patients as a property?
public Ward(string name,int patient )
{
Name = name;
Patient = new int[i];//currently giving error
}
public string GetWardDetails()
{
return string.Format("{0}", Name);
}
}