I have the following code in my main:
if (opt1>0){
switch (opt1){
case 1:
System.out.println("New customer");
Customer.addCustomer();
customerList.add(new Customer(getName();getSurname());
break;
case 2:
System.out.println("Edit customer");
break;
case 3:
System.out.println("Delete customer");
break;
case 4:
System.out.println("List of customers");
for(int i= 0; i<customerList.size(); i++){
System.out.println(customerList.get(i).getName());
}
break;
case 5:
System.out.println("Invalid Option, Please choose a number between 1 and 3");
Customer.showMenu();
break;
}
opt1 = 0;
}else{
System.out.println("Invalid Option");
System.out.println("Option has to be a number between 1 and 3");
}
}
and my addCustomer method is inside the Customer class and is the following
public static void addCustomer(){
System.out.println("Name:");
setName(name);
System.out.println("SurName:");
setSurname(surname);
System.out.println("E-mail:");
setEmail(email);
System.out.println("Phone Number:");
setPhone(email);
}
and the method setName and setSurname etc I have them like this:
public void setName() {
Scanner inputName = new Scanner(System.in);
String name = inputName.nextLine();
}
public void setSurname(String surname) {
Scanner inputSurname = new Scanner(System.in);
surname = inputSurname.nextLine();
}
I believe that up to the Customer.addCustomer () part; The switch works fine but I can not add the data obtained through the keyboard to the Customer type arraylist.
customerList.add(new Customer(getName();getSurname());
could someone show me the correct way to add the data of the object to an arraylist I've been trying for several days and I do not succeed.