みなさん、こんにちは私はこの質問を持っている:
銀行システムは、銀行Accounts
とCustomers
についての情報を格納する必要があります。銀行は2つの異なるタイプの勘定科目(小切手と貯蓄)をサポートしています。すべての銀行口座はNumber
、残高はdate opened
です。 2つの操作はすべてのアカウントに対して定義されます。makeDeposit()
とmakeWithdrawal()
です。チェック勘定にはチェックスタイルと最小残高の追加属性があります。アカウントの保存には、金利の追加属性と操作calculateInterest()
があります。集約と継承関係
お客様はすべてname
、address
、およびphone number
です。さらに、顧客は必要な数のアカウントを持つことができます。
上記の仕様は、次のように新しい要件で拡張されました。2種類の特別なタイプの顧客(Personal
およびCommercial
)があります。商業顧客には、信用格付け、連絡先、連絡先電話に関する追加属性があります。個人顧客はhome phone
とwork phone
の属性を持っています。さらに、モデルを展開して、銀行に複数の支店があり、各支店に1つの支店がサービスされていることを示します。もちろん、各ブランチには多くのアカウントがあります。
シンプルなテストプログラムを作成します(GUIや例外処理を使用する必要はなく、単純にしてください)。このテストプログラムの名前はBank.java
です。上記のクラスを使用する必要があります。 Bank.java
は、すべての銀行口座を保持するようにArrayList
と宣言する必要があります。テストプログラムは、システム機能を利用する必要があります。以下は、システム機能を示すサンプル操作です。
a。シカゴの支店の商業顧客のためのチェック勘定を作成し、それを配列リストに追加します
b。顧客情報と勘定残高を表示する別の方法を作成します。前の手順で作成した顧客の代わりにメソッドを呼び出します。
c。 'a'で作成したアカウントに$ 100を入金し、新しい情報を表示します。
d。初期残高$ 100、利率10%のブランチで個々の顧客の貯蓄勘定を作成し、それを配列リストに追加します。 e。 e。貯蓄口座情報を表示する
f。貯蓄口座に$ 100の預金をし、利子を計算してから、情報を表示してください。
g。あなたの選択の他の操作を実装する!
Bank.java
クラス以外のすべてを書いたコードです。どこから始めたらよいかわからない、どうすればいいですか?
ここでは、私のコードを見つけることができます:あなたは、クラスオブジェクトと正しい方向に向かっているよう
public abstract class Account{
protected String accountNumber;
protected double balance;
protected String dateOpened;
protected Customer state;
protected Customer customer;
public Account(){
this.accountNumber = "";
if (balance < 0)
balance = 0.0;
this.balance = 0.0;
this.dateOpened = "";
state = null;
customer = null;
}
public Account (String accountNumber,double balance,String dateOpened, Customer state,Customer customer){
this.accountNumber = accountNumber;
this.balance = balance;
this.dateOpened = dateOpened;
this.state = state;
this.customer = customer;
}
public void setCustomer(Customer customer){
this.customer = customer;
}
public Customer getCustomer(){
return customer;
}
public void setState(Customer state){
this.state = state;
}
public Customer getState(){
return state;
}
public void setAccountNumber(String accountNumber){
this.accountNumber = accountNumber;
}
public String getAccountNumber(){
return accountNumber;
}
public void setBalance(double balance){
this.balance = balance;
}
public double getBalance(){
return balance;
}
public void setDateOpened(String dateOpened){
this.dateOpened = dateOpened;
}
public String getDateOpened(){
return dateOpened;
}
public void makeDeposit(double depositAmount) {
balance = balance + depositAmount;
}
public void makeWithdrow(double withdrowAmount){
balance = balance - withdrowAmount;
}
public String toString(){
String output = "";
output += "\nCustomer State: " + this.state;
output += "\nCustomer Customer: " + this.customer;
output += "\nAccount Number: " + this.accountNumber;
output += "\nAccount Balance: " + this.balance;
output += "\nAccount Date Opened: " + this.dateOpened;
return output;
}
}
public class Customer {
protected String name;
protected String address;
protected String phone;
public Customer(){
this.name = "";
this.address = "";
this.phone = "";
}
public Customer(String name,String address,String phone){
this.name = name;
this.address = address;
this.phone = phone;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setAddress(String address){
this.address = address;
}
public String getAddress(){
return address;
}
public void setPhone(String phone){
this.phone = phone;
}
public String getPhone(){
return phone;
}
public String toString(){
String output = "";
output += "\nCustomer Name: " + this.name;
output += "\nCustomer Address: " + this.address;
output += "\nCustomer Phone: " + this.phone;
return output;
}
}
public class CheckingAcount extends Account {
private String checkStyle;
private String minumumBalance;
public CheckingAcount(){
this.checkStyle = "";
this.minumumBalance = "";
}
public CheckingAcount(String checkStyle,String minumumBalance){
this.checkStyle = checkStyle;
this.minumumBalance = minumumBalance;
}
public CheckingAcount(String checkStyle,String minumumBalance,String accountNumber,double balance,String dateOpened,Customer state,Customer customer){
super(accountNumber,balance,dateOpened,state,customer);
this.checkStyle = checkStyle;
this.minumumBalance = minumumBalance;
}
public CheckingAcount(String accountNumber,double balance,String dateOpened,Customer state,Customer customer){
super(accountNumber,balance,dateOpened,state,customer);
}
public void setCheckStyle(String checkStyle){
this.checkStyle = checkStyle;
}
public String getCheckStyle(){
return checkStyle;
}
public void setMinumumBalance (String minumumBalance){
this.minumumBalance = minumumBalance ;
}
public String getMinumumBalance(){
return minumumBalance ;
}
public String toString(){
String output = "";
output += "\nAccount Number: " + this.accountNumber;
output += "\nAccount Balance: " + this.balance;
output += "\nAccount Date Opened: " + this.dateOpened;
output += "\nChecking Account Check Style: " + this.checkStyle;
output += "\nChecking Account Minumum Balance: " + this.minumumBalance;
return output;
}
}
public class SavingAccount extends Account {
private double intrestRate;
public SavingAccount(){
this.intrestRate = 0.0;
}
public SavingAccount(double intrestRate){
if (intrestRate < 0)
intrestRate = 0.0;
this.intrestRate = intrestRate;
}
public SavingAccount(double intrestRate, String accountNumber,double balance,String dateOpened,Customer state,Customer customer){
super(accountNumber,balance,dateOpened,state,customer);
if (intrestRate < 0)
intrestRate = 0.0;
this.intrestRate = intrestRate;
}
public SavingAccount(String accountNumber,double balance,String dateOpened,Customer state,Customer customer){
super(accountNumber,balance,dateOpened,state,customer);
}
public void setIntrestRate(double intrestRate){
this.intrestRate = intrestRate;
}
public double getIntrestRate(){
return intrestRate;
}
public double calculateInterest() {
return intrestRate;
}
public String toString(){
String output = "";
output += "\nAccount Number: " + this.accountNumber;
output += "\nAccount Balance: " + this.balance;
output += "\nAccount Date Opened: " + this.dateOpened;
output += "\nSavingAccount Intrest Rate: " + this.intrestRate;
return output;
}
}
public class Personal extends Customer {
private String homePhone;
private String workPhone;
public Personal(){
this.homePhone = "";
this.workPhone = "";
}
public Personal(String homePhone,String workPhone){
this.homePhone = homePhone;
this.workPhone = workPhone;
}
public Personal(String homePhone,String workPhone,String name,String address,String phone){
super(name,address,phone);
this.homePhone = homePhone;
this.workPhone = workPhone;
}
public Personal(String name,String address,String phone){
super(name,address,phone);
}
public void setHomePhone(String homephone){
this.homePhone = homephone;
}
public String getHomePhone(){
return homePhone;
}
public void setWorkPhone(String workPhone){
this.workPhone = workPhone;
}
public String getWorkPhone(){
return workPhone;
}
public String toString(){
String output = "";
output += "\nCustomer Name: " + this.name;
output += "\nCustomer Address: " + this.address;
output += "\nCustomer Phone: " + this.phone;
output += "\nPersonal Home Phone: " + this.homePhone;
output += "\nPersonal Work Phone: " + this.workPhone;
return output;
}
}
public class Commercial extends Customer {
private double cridetRating;
private String contactPerson;
private String contactPersonPhone;
public Commercial(){
this.cridetRating = 0.0;
this.contactPerson = "";
this.contactPersonPhone = "";
}
public Commercial(double cridetRating,String contactPerson,String contactPersonPhone){
this.cridetRating = cridetRating;
this.contactPerson = contactPerson;
this.contactPersonPhone = contactPersonPhone;
}
public Commercial (double cridetRating,String contactPerson,String contactPersonPhone,String name,String address, String phone){
super(name,address,phone);
this.cridetRating = cridetRating;
this.contactPerson = contactPerson;
this.contactPersonPhone = contactPersonPhone;
}
public Commercial (String name, String address, String phone){
super (name,address,phone);
}
public void setCridetRating(double cridetRating){
this.cridetRating = cridetRating;
}
public double getCridetRating(){
return cridetRating;
}
public void setContactPerson(String contactPerson){
this.contactPerson = contactPerson;
}
public String getContactPerson(){
return contactPerson;
}
public void setContactPersonPhone(String contactPersonPhone){
this.contactPersonPhone = contactPersonPhone;
}
public String getContactPersonPhone(){
return contactPersonPhone;
}
public String toString(){
String output = "";
output += "\nCustomer Name: " + this.name;
output += "\nCustomer Address: " + this.address;
output += "\nCustomer Phone: " + this.phone;
output += "\nCommercial Cridet Rating: " + this.cridetRating;
output += "\nCommercial Contact Person: " + this.contactPerson;
output += "\nCommercial Contact Person Phone: " + this.contactPersonPhone;
return output;
}
}
多くの人々はさまざまな理由でリンクをたどりません。あなたのコードを含まないことで、あなたの質問に対する答えを見つけるチャンスが減ります。あなたはまた、投票を受けることもできます。 – MikeT
あなたが何かを成し遂げたいと思っても、何かをコーディングしてもらえないのですが、あなたが立ち往生していれば質問できます。 – prasanth
私のコードを入れました。 – Skarali