バンキング アプリを作成しています。番号 1 から始まる顧客番号を生成し、ループに入るたびに繰り返されないように番号を追跡し、使用できる int 変数に格納する必要があります。値を収集し、ループの外で customerNumber 変数に渡します。配列リストや配列など、いくつか試してみましたが、必要な変数に値を渡す際に問題が発生していました。事前に感謝し、私のひどい初心者で申し訳ありません...私はプログラミングの初心者です...これまでのところ、次のとおりです。
import java.util.ArrayList;
public class Bank{
public void addCustomer(String name, int telephone, String email, String profession) {
ArrayList customerList = new ArrayList();
Customer customer = new Customer();
customerList.add(customer);
}
}
public class Customer{
private String name;
private int telephone;
private String email;
private String profession;
private int customerNumber;
public Customer() {
}
}
public class Menu {
Scanner sc = new Scanner(System.in);
Bank bank = new Bank();
private void createCustomer() {
String name, email, profession;
int telephone, customerNumber;
System.out.println("Enter the customer's number: ");
name = sc.nextLine();
System.out.println("Enter the customer's telephone: ");
telephone = sc.nextInt();
System.out.println("Enter the customer's email: ");
email = sc.nextLine();
System.out.println("Enter the customer's profession: ");
profession = sc.nextLine();
bank.addCustomer(name, telephone, email, profession);
}
}