In my CustomiseParts method, there is an option where the user can return to the beginning of the program again, yet I am not sure how to execute this. All of the necessary code is below, how would I make it so the user can return to the top main() again?
public static void main(String[] args) {
Login();
AssignBudget();
CustomiseParts();
}
CodePudding user response:
Your CustomiseParts
method could return a boolean
indicating if the program must do another loop or not:
do {
Login();
AssignBudget();
} while(CustomiseParts());
CodePudding user response:
All you need, is to transfer everything the main method does, to another method and call it in main:
public class main {
public static void main(String[] args) {
someMethod();
}
public void someMethod(){
login();
assignBudget();
customiseParts();
}
public void customiseParts(){
//....your code
//the option to return to the beginning of the program again
if(....){
someMethod();
}
}
}
This way you can return to the start whenever you want, just by calling the someMethod().