使用java制作ATM程序时要解决的两个错误
我正在制作一个ATM软件,下面是创建一个新帐户的管理方法。 我在“currball=curr;”行的参数化因子的最大数量中得到一个错误 在执行此操作时,下一个错误出现在createnewAccount方法中: 客户账户=新客户账户、计数、统计、类型、SBal、日志、Pin; 错误说明参数的数量与构造函数的数量不匹配。请解释我的错误使用java制作ATM程序时要解决的两个错误,java,error-handling,Java,Error Handling,我正在制作一个ATM软件,下面是创建一个新帐户的管理方法。 我在“currball=curr;”行的参数化因子的最大数量中得到一个错误 在执行此操作时,下一个错误出现在createnewAccount方法中: 客户账户=新客户账户、计数、统计、类型、SBal、日志、Pin; 错误说明参数的数量与构造函数的数量不匹配。请解释我的错误 import java.util.*; class Customer { private String name;
import java.util.*;
class Customer
{
private String name;
private int accountno;
private String status;
private String type;
private int currbal;
private String Login;
private int Pin;
public void Customers()
{
this.name = " ";
this.accountno = accountno;
this.currbal = currbal;
}
public void Customers( String name1, int A, int Bal)
{
name = name1;
accountno = A;
currbal = Bal;
}
public void Customers ( String name1,int accountno1, String status1, String type1, int curr, String Login1, int Pin1)
{
name = name1;
accountno = accountno1;
status = status1;
type = type1;
currball = curr;
Login = Login1;
Pin = Pin1;
}
public String getHolderName()
{
return name;
}
}
class ATMmain
{
public static void main()
{
int count = 0;
Customer [] Carray = new Customer [100];
Customer [] C1 = new Customer[1];
System.out.println(createNewAccount(count, C1));
}
public static int createNewAccount( int count, Customer [] Carray)
{
//Customer [] Carray = new Customer[10];
System.out.println("Enter account information");
Scanner S = new Scanner (System.in);
System.out.println("Login:");
String log = S.next();
System.out.println("Pin Code:");
int Pin = S.nextInt();
System.out.println("Holder's name: ");
String holderN = S.next();
System.out.println("Type:" );
String type = S.next();
if (type != "Savings" || type != "Current")
{
System.out.println("error type! please Re-enter");
System.out.println("Type:" );
type = S.next();
}
System.out.println("Starting Balance:");
int SBal = S.nextInt();
System.out.println("Status:");
String Stat = S.next();
Customer ACC = new Customer(holderN, count,Stat, type,SBal,log, Pin );
Carray[count] = ACC;
System.out.println("Account Successfully created!");
System.out.println("account number is" +count);
count++;
}
public void DeleteExistingAcc(int count, Customer [] Carray )
{
System.out.println ("Enter Account Number: ");
Scanner S = new Scanner(System.in);
int acc = S.nextInt();
System.out.println("Are you sure you want to delete this Account:" +acc);
Carray[acc].getHolderName();
}
}
对。你的场地是足球而不是足球
你的第二个问题是,课程是客户而不是客户
我还注意到,您正在使用!=测试字符串相等性。这就是引用平等。使用String.equalString。而且,你的测试在逻辑上是不可能的。储蓄不是流动的
if (type != "Savings" || type != "Current")
应该是
if (!type.equals("Savings") && !type.equals("Current"))
这甚至没有编译。请阅读,非常感谢!:我知道这是一些愚蠢的怀疑,但我不明白!
if (type != "Savings" || type != "Current")
if (!type.equals("Savings") && !type.equals("Current"))