这些构造函数是未定义的

时间:2019-04-15 02:23:54

标签: java class constructor getter

我希望this.person0和this.person1正常运行,告诉我我不完全了解发生了什么,一位讲师给了我代码,并说修复错误,而我已经进行了不到一个月的编程。所有这些都让我烦恼,修复代码虽然不错,但是解释更好,我曾尝试在此处查看其他答案,但是除非它之间的联系足够紧密,否则我将无法理解。

public class BankApp {

    public static void main(String args[]) {
        BankApp ba = new BankApp();
    class SavingsAccount {
    private String Balance;
    private String ID;
    private String Name;

        private SavingsAccount person0;
        private SavingsAccount person1;

    public void BankApp() {

// A SavingsAccount object cannot be created without an ID, name and an initial balance.
        this.person0 = new SavingsAccount("AL01", "Luis Alvarez", 1.00);
        this.person1 = new SavingsAccount("BE01", "Elizabeth Blackwell", 2000.00);
// The get... methods are accessors for various private member variables of that object
// Their return types must match the types of the member variables being returned.

        System.out.println(person0.getBalance() + " " + person0.getID() + " " + person0.getName());
                }

            }

    }
// The withdraw method takes an amount to withdraw as its parameter.
// Return values:
// true when there are sufficient funds (and when the withdrawal is performed).
// false when there are insufficient funds.
        if (this.person0.withdraw(1000))
            System.out.println("Done");
        else
            System.out.println("Insufficient funds");
//The deposit method takes an amount to deposit as its parameter. It does not perform
// the deposit if the value is negative.
        this.person1.deposit(1500);
//The transfer method takes a beneficiary SavingsAccount object and an amount as its parameters
// then transfers that amount if sufficient funds are present in the "from" account object.
// Return values: Similar to the withdraw method above.
        if (this.person1.transfer(this.person0, 50000))
            System.out.println("Done");
        else
            System.out.println("Insufficient funds");
        System.out.println("Balance for " + this.person0.getID() + " = " + this.person0.getBalance());
        System.out.println("Balance for " + this.person1.getID() + " = " + this.person1.getBalance());

    }
    }


    }
}

0 个答案:

没有答案