This is probably simple but i dont know how to solve
I have class which contains this method, it taks an object p from another class called Person
public void addPerson(Person p)
{
aPerson.add(p);
}
And another method which is a simple menu
public void mainMenu()
{
// Create Menu Text
System.out.println(" Main Menu");
System.out.println("---------------------------------------------");
System.out.println("Please choose an option by entering the appropriate number:");
System.out.println("1. Add Person");
System.out.println("2. Exit");
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
try{ String menuC = stdIn.readLine();
int menuChoice = Integer.parseInt(menuC);
// Define Menu Options
switch(menuChoice)
{
case 1:
addPerson(Person p);
break;
case 2: //** Exit
break;
}
}
catch ( IOException ioe )
{
// won't happen too often from the keyboard
}
}
I want the method addPerson to be called if i type 1, however i get the error ')' expected on the line where i call the method in case 1.
If i take Person p as a parameter for mainMenu and then just call addPerson(p); it works perfectly, however i need it to want the parameter when the addPerson method is called not the mainMenu.
Any help on how to properly call the menu is appreciated.