Hey, i am struggling with this program, i have tried everything i can think of but it still says missing return statement on public String processInput(String theInput){
package clientserverassignment;
import java.net.*;
import java.io.*;
public class Protocol1 {
private static final int WAITING = 0;
private static final int SENTTOS = 1;
private static final int SENTMENU = 2;
private static final int ANOTHER = 3;
private int state = WAITING;
private String[] resource = {"A Computer Program", "A Picture", "An E-book"};
private String[] description = {"A program that says hello", "A humourous IT pic", "A book full of random stuff"};
public String processInput(String theInput) {
String theOutput = null;
String menu = null;
switch (state) {
case WAITING: {
theOutput = "Do you accept the TOS?";
state = SENTTOS;
return theOutput;
}
case SENTTOS: {
if (theInput.equalsIgnoreCase("Yes")) {
menu = resource[0];
for (int i = 1; i < resource.length; i++) {
menu = menu + resource[i];
}
theOutput = menu;
state = SENTMENU;
return theOutput;
} else {
if (theInput.equalsIgnoreCase("No")) {
theOutput = "Bye";
return theOutput;
} else {
theOutput = "Invalid choice. Do you accept the TOS?";
state = SENTTOS;
return theOutput;
}
}
}
case SENTMENU: {
int choice;
try {
choice = Integer.parseInt(theOutput);
if (choice <= 3 && choice >= 1) {
theOutput = description[choice - 1];
state = SENTMENU;
return theOutput;
} else {
theOutput = "Enter a number from the list you fucktard" + menu;
state = SENTMENU;
return theOutput;
}
} catch (NumberFormatException e) {
theOutput = "Wrong format for number, enter a valid choice " + menu;
state = SENTMENU;
return theOutput;
}
}
case ANOTHER: {
if (theInput.equalsIgnoreCase("Yes")) {
theOutput = menu;
state = SENTMENU;
return theOutput;
} else {
if (theInput.equalsIgnoreCase("No")) {
theOutput = "Bye";
return theOutput;
} else {
theOutput = "Invalid choice. Do you accept the TOS?";
state = SENTTOS;
return theOutput;
}
}
}
}
}
}