我在发送可变余额和存款以从 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;
}