You have been tasked with creating a program that models the diagnosing and subsequent curing of medical patients – Disease & Cure Administration (DCA). Let’s jump right into it.
The system revolves around a number of actors:
Your application should support a procedure like the one described below:
Abstract: A patient is defined by a name, a number describing his/her overall health (0-100%) and one or more symptoms. A patient with no symptoms should be at 100% health; correspondingly, a patient with any symptoms should have less than 100% health. It should be possible to heal the patient, and thus increasing his/her health. If the patient is restored to 100% health, he/she is relieved of all symptoms. A patient can never have above 100% health.
Implementation: You should provide a Patient class with fields as described above (name, health and symptoms) that honor the constraints listed as well as a heal method that can be called when curing the patient. Healing the patient should bring his/her health towards 100% and eventually remove any symptoms associated with the patient.
Abstract: A symptom is defined by a name and a severity level; the latter could be, for instance, “trivial”, “serious” or “life-threatening”. All symptoms are put in a file that can be read from disk; at application start, the symptoms are read from the disk and loaded into a registry. This registry makes it possible to access data about all known symptoms at any time.
Implementation: You should provide two classes: a Symptom class and a SymptomRegistry class. The Symptom class should include the fields described above (name and severity level). The SymptomRegistry class should load a list of symptoms from a text file (either by itself or through a helper class) and provide a way to retrieve one or all symptoms at once.
Example of contents of the text file: See image.
Abstract: A disease is defined by a name, a number of symptoms and a reference to the cure required to remove the condition from the patient. As with the symptoms, a registry provides easy access to all known diseases. The registry can also load the disease information from disk; however, it is not mandatory – it is OK if the disease information is created when the registry is initialized.
Implementation: You should provide two classes: a Disease class and a DiseaseRegistry class. The Disease class should include the fields described above (name, list of symptoms and cure). In a perfect world, there are no diseases that cannot be cured, so we assume that a cure will be available for any disease. The DiseaseRegistry should, as with the SymptomRegistry, provide a way to access one or all symptoms currently in the registry. You may, as with the SymptomRegistry, initialize it with a text file – this is however not mandatory (but otherwise, you should provide a way to easily add new diseases to the registry on-the- fly). Provide some test data in the form of a few diseases, complete with related symptoms.
Abstract: The doctor diagnoses the patient and suggests a cure. The diagnosis follows the below algorithm:
Implementation: You should provide a Doctor class with only one method (which might as well be static, since the doctor class contains no state). The method, diagnose, performs a diagnosis as described in the algorithm above. For the sake of simplicity, we assume that a patient is only suffering from a single disease at any given time.
Abstract: A cure is defined by a name and a health factor, the latter defining how many percent of health the cure heals the patient every time the cure is administered. Cures come in different fashions; examples are cures that are distributed in pill form and cures that are injected into the bloodstream. While these cures differ in the way they are administered, they work toward the same purpose: to bring the patient’s health up to 100% and eventually relieve him/her of any symptoms.
Implementation: You should provide a Cure class which serves as a superclass to any specific cure types. This class should have fields as described above (name and health factor) that can be used by the child classes, as well as an method for administering the cure, administer, which should be designed to be overridden by the child classes. The method takes a patient as parameter and subsequently calls that patient’s heal method with the cure’s health factor as a parameter. You should provide at least two child classes that represent different types of cure (e.g. PillBasedCure, InjectedCure) and each expose their own method of administering the cure (takePills, inject etc.). These methods should be called from the child classes’ overridden administer method.
When the system is ready, you should provide a test class with a main method to see if your system works the way it’s supposed to. At the bare minimum, test in this class that you can:
The below class diagram may be helpful for you in your implementation: See image.