P4 High-level Design


/*-------------------------------------------------------------------------*/

class Patient {

  friend ostream &operator<<(ostream &out, const Patient &p);
  friend istream &operator>>(istream &in, Patient &p);

  public:
    Patient();
    string getID();
    string getDiagnosis();
    void setDiagnosis(string newDiagnosis);
    void print();
    void enter();
    double similarity(const Patient &p);

  private:
    string id;
    int thickness;
    int sizeUniformity;
    int shapeUniformity;
    int adhesion;
    int epithelialSize;
    int bareNuclei;
    int blandChromatin;
    int normalNucleoli;
    int mitoses;
    string diagnosis;

}; // Patient class

Patient::Patient() --- Default constructor

string Patient::getID() --- Observer method for the id private data member.

string Patient::getDiagnosis() --- Observer method for the diagnosis private
data member.

void Patient::setDiagnosis(string newDiagnosis) --- Accessor method for the
diagnosis private data member.

void Patient::print() --- Prints a patient's information in a ``pretty''
format.  Should be used for console output.

void Patient::enter() --- Lets a user enter a patient's information from
the console with prompts.

double Patient::similarity(const Patient &p) --- Returns a double which
is a measure of similarity between the patient object and the argument p.
Although I'd recommend Euclidean distance, there are other distance
measures one could use, such as absolute distance and Manhattan distance.

ostream &operator<<(ostream &out, const Patient &p) --- Overloaded
stream insertion operator for Patient.  Use for file output.

istream &operator>>(istream &in, Patient &p) --- Overloaded stream
insertion operator for Patient.  Use for file input.

/*-------------------------------------------------------------------------*/

class PatientList
{

  public:
    void add(const Patient &p);
    void load(string filename);
    void save(string filename);
    Patient findMostSimilar(const Patient &p);

  private:
    vector<Patient> patients;

}; // PatientList class

void PatientList::add(const Patient &p) --- Adds the Patient object p
to the vector patients.

void PatientList::load(string filename) --- Loads the Patient records
into the vector patients from the file filename.

void PatientList::save(string filename) --- Saves the Patient records
in the vector patients to the file filename.

Patient PatientList::findMostSimilar(const Patient &p) --- For a given
Patient p, returns the most similar Patient in the vector patients.

/*-------------------------------------------------------------------------*/

This class is designed to encapsulate all of the functions for the user
interface.

class DiagnosticApp
{
  public:
    DiagnosticApp(string theFilename);
    void processCommands();

  private:
    string filename;
    PatientList pl;

}; // DiagnosticApp class

DiagnosticApp::DiagnosticApp --- default constructor.  Simply stores the
argument in the private data member filename, which is the name of the
file containing all of the patient records.

void DiagnosticApp::processCommands --- implements the main logic of the
application (i.e., the P4 flowchart).

/*-------------------------------------------------------------------------*/

int main()
{
  DiagnosticApp theApp("wbc.dta");
  theApp.processCommands();
  return 0;
} // main