I am supposed to create a class patient that will sort the patients according to their condition that is Serious(S), Routine(R), Critical(C), and Expectant (E). Use a heap based Priority Queue. The data type stored should be objects of class Patient. Class Patient will require a compare method that takes an argument of Patient class type that will return a Boolean based on comparing the Category member of the argument class vs this.Category. The Serve method of the Priority Queue should display the patient data of the next patient to be treated. The program is to be a Windows application
So far my code it builds successfully but upon running I get an error Format Exception was unhanded in the lines highlighted in bold.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Client
{
class Patient
{
private int patientnumber;
private string name;
private string timein;
private char condition;
// Default constructor:
public Patient()
{
name = "N/A";
}
// Constructor:
public Patient(string name, int patientnumber, char condition, string timein)
{
this.name = name;
this.patientnumber = patientnumber;
this.condition = condition;
this.timein = timein;
}
// Printing method:
public void PrintPatient()
{
[B] Console.WriteLine("{0}, {1} {3} {4} ", name, patientnumber, condition, timein)[/B];
}
}
class StringTest
{
static void Main()
{
// Create objects by using the new operator:
Patient patient1 = new Patient("Daniel Craig", 414092817, 'E', "12:45");
Patient patient2 = new Patient("Sally May", 654125419, 'S', "03:00");
// Create an object using the default constructor:
Patient patient3 = new Patient("Jomo Stronghold", 124891017, 'C', "11:20");
Patient patient4 = new Patient("Carlitos Way", 215210211, 'R', "12:20");
Patient patient5 = new Patient("Keith Baird", 215961011, 'C', "19:50");
Patient patient6= new Patient("Sony Webuye", 29154631, 'R', "12:20");
Patient patient7 = new Patient("Amy Whitehouse", 215961016, 'C', "21:00");
Patient patient8 = new Patient("Santos Abreza", 813694011, 'R', "10:20");
// Display results:
Console.Write("Patient #1: ");
patient1.PrintPatient();
Console.Write("Patient #2: ");
patient2.PrintPatient();
Console.Write("Patient #3: ");
patient3.PrintPatient();
Console.Write("Patient #4: ");
patient4.PrintPatient();
Console.Write("Patient #5: ");
patient3.PrintPatient();
Console.Write("Patient #6: ");
patient4.PrintPatient();
Console.Write("Patient #7: ");
patient3.PrintPatient();
Console.Write("Patient #8: ");
patient4.PrintPatient();
}
}
}