PurposeIn this homework, you will gain more experience using if/else-type statements by writing a so-called "expert system", or a program that behaves like a human expert for a particular type of problem. For this assignment you will develop a somewhat silly expert system based on many variations of a humorous flowchart floating around the Internet. You can see a more serious example of an expert system in the assignment from spring 2005. The problem domain being considered in this assignment is how to decide a career path for your favorite techie. Skeleton CodeWe have provided an initial version of the code (called skeleton code because it provides the framework or "skeleton" on which you will build) in ProblemSolver.java. In particular we supply the string constants you are to use for the questions, answers, and actions. You will also need to download and use the YesNoExtractor class contained in the file YesNoExtractor.class (right-click and select "save as"). The YesNoExtractor.class file must be in the same directory as the ProblemSolver.java file for your program to work correctly. Class YesNoExtractorThe YesNoExtractor class supports the following methods:
The FlowchartThe tool you will design and produce is based on the following diagram, which is based on several humorous versions found on the Net. All flowcharts show something -- this one shows how to figure out what career is best for your favorite techie (or perhaps you!).
This flowchart is a bit difficult to implement for this homework, so we are providing a slightly modified version below. It is the version below that you need to implement for this homework. It's essentially the same thing with a few changes (no loop back to start, etc.).
Note that for the "Start over" resolution, you just have to print that out -- your program should NOT start the entire flowchart again. In this diagram, as in most flowcharts, questions for the user (which will become calls to YesNoExtractor.askUser() in your code) are represented as diamonds. Final resolutions (which the program prints out before terminating) as ovals (in this diagram, either green or red). The particular answer (yes or no, for this flowchart) that moves to another box is listed on the arrow. Note that the "Start here" is just a indication of where to start, and need not be printed (although you should be printing a legend before you ask the first question). Currently the skeleton code implements only a single question of the flowchart, and doesn't do much else. Note that you should use the exact string constants given in the skeleton code -- you can just call System.out.println(A_START_OVER);, for example, to print out the resolution shown on the lower left of the flowchart. Note that there are certain parts of the flowchart that are repeated. In particular, there are 3 paths that can get you to the "Start Over" resolution. It's fine to have that resolution repeated throughout your code (i.e. you can have 4 separate print statements with that resolution, if you need to do so). Miscellaneous NotesThe good programming practices from HW J1 need to be in this homework as well. We are not providing a sample execution for this program. As the homeworks in the course progress, less detailed information will be provided, and it is up to you to fill in the detail that is left out (in this case, the execution run). This program will require both if-else-if statements, as well as nested if's. You MUST use if-else-if's in this homework. Lastly, note that you can call System.exit(0); from anywhere in your code. This will cause the Java program to immediately stop, even if it is in a nested if statement. Depending on how you write your program, you may not need to use this. SubmissionWhen you are finished, submit the ProblemSolver.java file. |