-1

我在发送可变余额和存款以从 Driver 转移到 BankAccount 时遇到问题,有人有什么建议吗?我正在使用 BlueJ。

这是驱动程序类和方法-

   import javax.swing.JOptionPane;
public class Driver
{
    int choice;
    String number;
    String name;
    double deposit;
    double withdraw;
    double balance;
    //public Driver()
    public Driver()
    {
         String number = JOptionPane.showInputDialog("1. Deposit 2. Withdraw 3. Balance 4. Change name 5. Exit");
         int choice = Integer.parseInt(number);
         do
         {
         if( choice == 1)
         {
             String input = JOptionPane.showInputDialog("How much would you like to deposit?");
             deposit = Integer.parseInt(input);
             BankAccount b = new BankAccount();
             b.Deposit();
             Driver a = new Driver();

这是 BankAccount 程序-

public class BankAccount
{
double balance = 400;
double deposit;
double withdraw;
double Interest = 1.05;
String name;
String accountNumber;

public double Deposit()
{
    //String input = JOptionPane.showInputDialog("How much would you like to deposit?");
    //deposit = Integer.parseInt(input);
    if (deposit < 10000)
    {
        balance = deposit + balance;

    }
    return balance;
}
4

1 回答 1

1

您必须在BankAccount课堂上使用您的 depost 方法,如下所示

public double Deposit(double deposit){

...........

}

你的云端硬盘课程应该是

...
    b.Deposit(deposit);
...

方法调用

于 2012-12-20T23:45:38.410 回答