You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: