Created
November 30, 2017 17:25
-
-
Save toriannnn/b567f20960a31f6ab5711f8152f81c34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//******************************************************************* | |
//Assignment: Program 2 | |
//Account: TAM154 | |
// | |
//Author: Tori Murray | |
// | |
//Completion Time: 1 hour | |
// | |
//Honor Code: I pledge that this program represents my own program code. | |
//I received help from Alex Nogy | |
//******************************************************************* | |
package problemsolver; | |
//import java.util.Scanner; --- INSTEAD of SCANNER we'll use YesNoExtractor class | |
import yesnoextractor.YesNoExtractor; // GIVEN to YOU in PROJECT SHELL | |
public class ProblemSolver { | |
public static void main(String args[]) { | |
// following constants are questions to be asked (diamonds in flowchart) | |
final String Q_HUMAN = | |
"Are you human?"; | |
final String Q_RESEMBLE_HUMAN = | |
"Do you resemble a human?"; | |
final String Q_MBA = | |
"Do you covet an MBA"; | |
final String Q_BARNEY = | |
"Is Barney more evil than Dr. Doom?"; | |
final String Q_DR_EVIL = | |
"Is Dr. Evil more evil than Dr. Doom?"; | |
final String Q_PROFESSOR = | |
"Are you a professor?"; | |
final String Q_DELL = | |
"Would you serve the Dell guy?"; | |
final String Q_RUN = | |
"You have angered your overlord. Do you run?"; | |
// following constants are resolutions to the problem (ovals) | |
final String A_CODING= | |
"Stick with coding. It is your Destiny!"; | |
final String A_THREAT= | |
"You're a threat to greater evil and will be treated as such."; | |
final String A_LIEUTENANT = | |
"You clearly cower in the presence of evil. You'll make a great lieutenant!"; | |
final String A_MINION = | |
"Your intellect is a bit dubious. You'll make a good minion."; | |
final String A_DOORSTOP= | |
"Well done! You'll make an excellent door stop."; | |
YesNoExtractor extractor = new YesNoExtractor(); | |
// start: Q: are you human? | |
if ( extractor.askUser(Q_HUMAN) ) { | |
// Q: Ask Q_MBA | |
if ( extractor.askUser(Q_MBA) ) { | |
// Answer is A_THREAT | |
System.out.println(A_THREAT); | |
} | |
else { | |
if ( extractor.askUser(Q_BARNEY) ) { | |
//Ask Q_RUN | |
if ( extractor.askUser(Q_RUN)) { | |
//Answer is Q_LIEUTENANT | |
System.out.println(A_LIEUTENANT); | |
} | |
else { | |
//Answer is A_MINION | |
System.out.println(A_MINION); | |
} | |
} | |
else { | |
//Ask Q_DR_EVIL | |
if (extractor.askUser(Q_DR_EVIL) ) { | |
//Answer is A_LIEUTENANT | |
System.out.println(A_LIEUTENANT); | |
} | |
else { | |
//Answer is A_MINION | |
System.out.println(A_MINION); | |
} | |
} | |
} | |
} | |
else { | |
//Ask Q_RESEMBLE_HUMAN | |
if ( extractor.askUser(Q_RESEMBLE_HUMAN) ) { | |
//Ask Q_PROFESSOR | |
if ( extractor.askUser(Q_PROFESSOR) ) { | |
//Answer is A_DOORSTOP | |
System.out.println(A_DOORSTOP); | |
} | |
else { | |
//Ask Q_DELL | |
if (extractor.askUser(Q_DELL) ) { | |
//Ask Q_DR_EVIL | |
if (extractor.askUser(Q_DR_EVIL) ) { | |
//Answer is A_LIEUTENANT | |
System.out.println(A_LIEUTENANT); | |
} | |
else { | |
//Answer is A_MINION | |
System.out.println(A_MINION); | |
} | |
} | |
else { | |
//Answer is A_DOORSTOP | |
System.out.println(A_DOORSTOP); | |
} | |
} | |
} | |
else { | |
//Answer is A_CODING | |
System.out.println(A_CODING); | |
} | |
} | |
} // end of main | |
} // end of ProblemSolver.java |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment