-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
void LinkedListPatientQueue::upgradePatient(string name, int newPriority) {
if (front == nullptr) { //error case
throw("Invalid Operation: The queue of patients is empty.");
} else {
PatientNode* current = front;
while (current->next != nullptr && current->next->name != name) {
current = current->next;
}
if (current->next == nullptr) { //error case
throw("Invalid Operation: There is no patient with the given name.");
} else {
PatientNode* toModify = current->next;
if (toModify->priority < newPriority) { //error case
throw("Invalid Operation: The priority of the patient is already greater than the"
" new priority.");
} else {
current->next = toModify->next;
newPatient(toModify->name, newPriority);
delete toModify; //preventing memory leak.
}
}
}
}
in linked list implementation cpp file, function upgradepatient, this code doesn't consider when you want to change the priority of frontname, an error would generate.
Metadata
Metadata
Assignees
Labels
No labels