I am creating a banking application for my assignment, I would like to know if it's possible to call another class from an if/else statement? if so, where have I gone wrong? as when before compiling I get no errors, but many errors when trying to run. I would like to call the 'public void currentAccountCreate in the currentAccount.java class. I also have a main menu page. many thanks
import java.util.Scanner;
public class Account {
Scanner keyboard = new Scanner(System.in);
currentAccount currentAccountCreating = new currentAccount();
//savingsAccount savingsAccountCreating = new savingsAccount();
public void accountCreation(){
String createOption = "";
boolean valid = false;
while(!valid){
System.out.println("What account would you like to create?");
System.out.println("Current or savings?");
createOption = keyboard.nextLine();
if (createOption.equalsIgnoreCase("current")){
currentAccountCreating.currentAccountCreate();
}
else {
System.out.println("Invalid account type selected. Please enter checking or savings");
}
}
}
}
Here's what I'm trying to call
public class currentAccount extends Account {
public void currentAccountCreate(){
Aucun commentaire:
Enregistrer un commentaire