Homework J4Due: Friday, 18 March 2005 by 10 a.m. |
A class DizzinessExpert.java meeting all assignment specifications. A template file is available.
The assignment will be discussed in the course meeting on Wednesday March 2, 2005 and somewhat on Monday March 7, 2005. As we indicate frequently, your active participation in class meetings will contribute positively to your education.
Instill interest in computing-based problem solving by exhibiting its societal utility for diagnostic problems.
Provide familiarity with computation-based decision making.
Demonstrate the power of object-oriented design and development through an early exposure to inheritance.
As a matter of professional ethics, we make the disclaimer that the tool that you will develop for this assignment is intended solely for pedagogical (teaching) purposes. The design and development of a true diagnostic tool requires interaction with medical personnel, testing in controlled environments to determine the validity of the program, and official certification. For information on the professional code for computer scientists, visit the ACM website www.acm.org. The ACM is the major professional society of computer scientists.
This assignment builds upon the problem solving and class development knowledge and skills that you have obtained by participating in this course. In particular, this assignment has you develop a class for representing and manipulating a medical condition diagnostic tool.
A diagnostic tool is an example of expert systems. An expert system behaves like a human expert for a particular problem domain. The problem domain being considered in this assignment is dizziness.
Expert systems are typically rule-based, where a rule has two components. The first component is the conditions under which the rule is applicable; the second component is the recommended action under those conditions. To determine which rule applies, a rule-based expert system typically performs a series of queries to determine the situation at hand. The queries are normally done in a manner that uses responses from previous queries to determine future queries. Such a process enables the program to determine quickly the specifics of the situation.
The tool you will design and produce is based on the following diagram, which is a simplification of an American Medical Association procedure for dealing with dizziness in their reference The American Medical Association Family Medical Guide: Fourth Edition, Wiley, ISBN 0-471-26911-5, 2004.
Your solution DizzinessExpert.java must provide the following capabilities:
A public default constructor method DizzinessExpert() whose recommendation is initially "Insufficient information to make any diagnosis."
A public accessor (inspector) method getRecommendation() that returns a String representing the current recommendation of the DizzinessExpert.
A private mutator method setRecommendation(String advice) that sets the current recommendation of the DizzinessExpert to advice. The method is not publicly available because it would be inappropriate to provide the means for a deliberate misdiagnosis.
A public facilitator method queryUser() that sets the current recommendation of the DizzinessExpert based on an "interview" with the tool user according to the dizziness diagram.
Based on this specification, we suggest a private String instance variable recommendation that maintains the current recommendation of the DizzinessExpert. However, it is up to you how to provide the necessary capabilities.
The first three methods listed in the requirements have straightforward implementations -- they merely involve the setting or accessing of the recommendation of the DizzinessExpert. The fourth method is more involved -- it requires a decision structure that implements the dizziness diagram.
To ease the implementation burden of the queryUser() method, the solution template file defines a set of String variables representing the various recommendations and interview questions. We very strongly suggest that use them.
To further ease your implementation burden you are welcomed to use a class Extractor that we have developed. Class Extractor supports the extraction of input. If you choose to download the file Extractor.class, then your DizzinessExpert solution has access to the following Extractor methods (among others).
public Extractor()
Configures the new Extractor so that it displays messages to standard output and extracts information from standard input; that is the Extractor interacts with streams System.out and System.in.
public boolean queryForYesOrNo(String message)
Causes the Extractor to query the user for a yes or no response with regard to the message. If the user indicates yes, then true is returned. If the user indicates no, then false is returned. If the user indicates something else, then the query is reissued until a proper reply is given.
So what use is Extractor to you? Consider the follow code segment that could begin an implementation of the DizzinessExpert instance method queryUser().
public void queryUser() {
Extractor stream = new Extractor();
if ( ! stream.queryForYesOrNo( LIGHT_HEADED_QUESTION ) ) {
setRecommendation( INSUFFICIENT_ABILITY_DIAGNOSIS );
} ...
where LIGHT_HEADED_QUESTION and INSUFFICIENT_ABILITY_DIAGNOSIS are String variables defined in the template file and setRecommendation() is your DizzinessExpert method.
To test your class you should use a method main() that creates and uses a DizzinessExpert . The program could be run multiple times to determine whether each diagnosis is correctly determined. A sample method main() is
public static void main(String[] args) {
System.out.println ("\nWelcome to our expert system that will "
+ "diagnose why you are dizzy.\n\n");
DizzinessExpert expert = new DizzinessExpert();
expert.queryUser();
String result = expert.getRecommendation();
System.out.println ("The diagnosis is: " + result + "\n");
}