Created
March 31, 2023 06:34
-
-
Save kinarajv/d70c249652032a32bb717b3e4a1477d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main() | |
{ | |
PatientQueue pq = new PatientQueue(); | |
pq.Enqueue(new Patient("John", 1)); | |
pq.Enqueue(new Patient("Mary", 2)); | |
pq.Enqueue(new Patient("Peter", 3)); | |
List<Patient> pqe = pq.ToList(); | |
foreach(Patient p in pqe) | |
{ | |
Console.WriteLine(p.Name + " " + p.Priority); | |
} | |
} | |
} | |
class PatientQueue | |
{ | |
private Queue<Patient> patients = new Queue<Patient>(); | |
public void Enqueue(Patient patient) | |
{ | |
patients.Enqueue(patient); | |
} | |
public List<Patient> ToList() | |
{ | |
return patients.ToList(); | |
} | |
} | |
class Patient | |
{ | |
public string Name { get; set; } | |
public int Priority { get; set; } | |
public Patient(string name, int priority) | |
{ | |
Name = name; | |
Priority = priority; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment