/**
* Implements a technical support system. It contains a loop that repeatedly
* reads input and generates output until the user wnats to leave
*
* @author (prabu)
* @version (2020/11/9)
*/
import java.util.*;
public class SupportSystem
{
private InputReader reader;
private Responder responder;
/**
* Create a technical support system
*/
public SupportSystem()
{
reader = new InputReader();
responder = new Responder();
}
/**
* Start the technical support system. This will print a welcome message
* and enter into a dialog with the user, until the user ends the dialog.
*/
public void start()
{
boolean finished = false;
printWelcome();
printFAQ();
while(!finished)
{
String option = reader.getOptionInput();
if(option.compareTo("1") == 0)
{
System.out.println(responder.getFAQ(1));
}
else if(option.compareTo("2") == 0)
{
System.out.println(responder.getFAQ(2));
}
else if(option.compareTo("3") == 0)
{
System.out.println(responder.getFAQ(3));
}
else if(option.compareTo("4")==0)
{
boolean finish = false;
System.out.println("******");
System.out.println("Tell us about your problem!");
System.out.println("(Type \'bye\' to exit the system)");
while(!finish)
{
HashSet<String> input = reader.getInput();
if(input.contains("bye"))
{
finish = true;
finished = true;
}
else
{
String response = responder.generateResponse(input);
System.out.println(response);
}
}
}
else if(option.compareTo("bye")==0)
{
break;
}
else
{
System.out.println("Invalid Input!\\n");
}
}
printGoodBye();
}
/**
* Print the FAQ message to the screen
*/
private void printFAQ()
{
System.out.println("1. "+
"The program won\'t start.");
System.out.println("2. "+
"The program won\'t exit.");
System.out.println("3. "+
"The program is running slow.");
System.out.println("4. "+
"...or tell us your problems.");
}
/**
* Print Welcome message to the screen
*/
private void printWelcome()
{
System.out.println("Welcome to Technical Support System!\\n"+
"***");
System.out.println(responder.generateGreeting() +
"Is there anything I can help you with?\\n"+
"(Type \'bye\' to exit our system)");
}
/**
* Print goodbye message to the screen
*/
private void printGoodBye()
{
System.out.println("Nice talking to you. Bye...");
}
}