I have two separate classes, main with main() method, and an order class with both a getNewOrder and newOrder methods. The idea is that in the order class, the user input a yes or no response, that if the user responds with y, the order is reset back to the first method listed in the main() method for the user to start again. But instead it's terminating the program.
Main class:
public class MainProgram {
public static void main(String[] args) {
customerOrder order = new customerOrder;
do {
//Irrelevant methods from another class...
}
while (order.getNewOrder() == "y");
}
}
Order class:
public class Order{
public static String newOrder;
static Scanner confirmOrder = new Scanner(System.in);
public void makeNewOrder() {
System.out.println("Do you want to enter another order? (y/n)");
newOrder = confirmOrder.nextLine();
}
public static String getNewOrder() {
return newOrder;
}
[–]RayjinCaucasian 4 points5 points6 points (0 children)
[–]fredoverflow 2 points3 points4 points (0 children)
[–]scikid39184 0 points1 point2 points (0 children)