asset class Prescription {…}
interface Pharmacy {
void depositPrescription(owned Prescription >> unowned Prescription p);
owned Prescription removePrescription(Prescription @ Unowned p);
unowned Prescription getAnyPrescription();
}
class Patient {
void fillPrescription(unowned Pharmacy pharmacy, unowned Prescription pre) {
pharmacy.depositPrescription(pre); // Location (A)
unowned Prescription pre2 = pharmacy.getAnyPrescription();
owned Prescription removedPrescription = pharmacy.removePrescription(pre2); // Location (B)
pharmacy.depositPrescription(removedPrescription); // Location (C)
}
}
For each location where the compiler will give an error, check the corresponding box and explain why there is an error.