Я пытаюсь создать программу для банковского счета, в которой пользователь может вводить типы счетов "s" или "S" для сберегательного счета.Они также могут ввести «c» или «c» для текущего счета.У меня проблемы с тем, чтобы пользовательский ввод выполнялся через методы getter / setter, а затем возвращал на выходе строку "Savings" или "Checking" в зависимости от ввода.
package com.company;
import javax.swing.*;
public class Main {
public static void main(String[] args) {
BankAccount myBank = new BankAccount();
myBank.setAccountType(JOptionPane.showInputDialog("please enter an account type"));
JOptionPane.showMessageDialog(null, "Account Number: " + "\nAccount Type: " + myBank.getAccountType() +"\nMinimum Balance: "+ "\nBalance Before Interest and Fees: " + "\n\nNew Balance:\n");
}
}
BankAccount
класс
package com.company;
public class BankAccount {
private int accountNumber;
private String accountType;
private double minSavings = 2500;
private double minChecking = 1000;
private double currentBalance;
public BankAccount(){ }
public String getAccountType () {
return this.accountType;
}
public void setAccountType (String please_enter_an_account_type) {
if (accountType == "S" || accountType == "s") {
this.accountType = "Savings";
}
else if (accountType == "C" || accountType == "c") {
this.accountType = "Checking";
}
}
}