Cześć, dostałem wskazówkę by przerobić w programie metody które u mnie mają `void`,ale maja: get, compute, create, build.... etc. w nazwie na metody, które zwracają.
Np:
private void getOptionsOfMainMenu(int option) {
if (option >= 1 && option <= 2) {
switch (option) {
case 1:
inputLoginAndPassword();
accountMaker.createAccount(login, password);
System.out.println("Now let's log into you account.");
case 2:
while (loopIsTrue) {
inputLoginAndPassword();
if (!accountLogger.isLoginDataIncorrect(login, password)) {
loopIsTrue = false;
}
}
break;
}
}
tutaj, żeby zwracało tę listę opcji.
Ta metoda, łaczy się z tą metodą:
void displayMainMenu() {
System.out.println("What do you wanna to do?");
System.out.println("1. Add Account 2. Log into my account");
while (loopIsTrue) {
try {
getOptionsOfMainMenu(input.nextInt());
} catch (InputMismatchException e) {
System.out.println("You've inputed something wrong!");
System.out.println("What do you wanna to do?");
System.out.println("1. Add Account 2. Log into my account");
input.next();
}
}
}
Potrzbuje jakiegos przykladu, zeby móc pozniej przerobić inne metody.