Java代写:一个简单的query system

用java实现一个给定流程图的query system. 收集用户输入,进入特定分支并给出正确回应。

Purpose
In this homework, you will gain more experience using if/else-type statements by writing a so-called “query 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. The problem domain being considered in this assignment is “how to decide your role in serving an evil genius.”

Skeleton Code
Provided is an initial version of the code (called skeleton code because it provides the framework or “skeleton” on which you will build) in the Zip of a ProblemSolver NB project. In particular, the string constants you are to use for the questions, answers, and actions. Also provided the YesNoExtractor.class (embedded in the project library).

Class YesNoExtractor - This class replaces the need for Scanner
The YesNoExtractor class has the following 2 methods: • public YesNoExtractor() ◦ This default constructor configures the new YesNoExtractor so that it displays messages to standard output and extracts information from standard input; that is, the YesNoExtractor reads input from the keyboard (System.in) and writes to the screen (System.out). • public boolean askUser(String message) ◦ Causes the YesNoExtractor to query the user for a yes or no response after printing 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 question is reissued until a proper reply is given.

The Flowchart
The 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 which role you are suited to if you were to serve an evil genius.

kamisama wechat
KamiSama