Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** Define a new class SavingsAccount, which is a subclass of BankAccount. */ public class SavingsAccount extends BankAccount{ private double annualInterestRate; /** Using this method

image text in transcribed

image text in transcribed

/** Define a new class SavingsAccount, which is a subclass of BankAccount. */ public class SavingsAccount extends BankAccount{ private double annualInterestRate;

/** Using this method can access the annualInterestRate. @param none this method takes no argument @return one year deposit rate */ public double getAnnualInterestRate(){ return annualInterestRate; }

/** Using this method can update the annualInterestRate. @param newAnnualInterestRate a new one year deposit rate @return this method does not return anything */ public void setAnnualInterestRate(double newAnnualInterestRate){ if (newAnnualInterestRate >= 0.0) annualInterestRate = newAnnualInterestRate; }

/** When creating an new object,if no arguments provided, using this constructor to initialize it. @param none this method takes no argument @return this method does not return anything */ public SavingsAccount(){ super(); annualInterestRate = 0.0; }

/** When creating an new object,this constructor initializes the balance and annualInterestRate using the arguments @param balance balance the remaining in the account @param annualInterestRate one year deposit rate @return this method does not return anything */ public SavingsAccount(double initialBalance, double initialAnnualInterestRate){ super(initialBalance); annualInterestRate = initialAnnualInterestRate; } /** When creating an new object,this constructor initializes the balance and customer using the arguments @param customer a variable that represents the account owner, including information of name and ID @param balance the remaining in the account @return this method does not return anything */ public SavingsAccount(Customer initialCustomer, double initialBalance){ super(initialCustomer, initialBalance); } /** When creating an new object,if no arguments provided, using this constructor to initialize it. @param none this method takes no argument @return this method does not return anything */ public void depositMonthlyInterest(){ if (getBalance( ) > 0.0){ double interest = annualInterestRate/100.0/12*getBalance(); deposit (interest); } } }

-----------------------------------------------------------------------------------------------------------------------------------

/**

Class for customer data?name and customerID.

*/

public class Customer{

private String name;

private int customerID;

/**

Using this method can access the customer's name.

@param none this method takes no argument

@return name

*/

public String getName()

{

return name;

}

/**

Using this method can update the customer's name.

@param name a new name

@return this method doesn't return anything

*/

public void setName(String name)

{

this.name = new String(name);

}

/**

Using this method can access the customerID.

@param none this method takes no argument

@return customer's ID

*/

public int getID()

{

return customerID;

}

/**

Using this method can update the customerID.

@param id a new customer's ID

@return this method doesn't return anything

*/

public void setID(int id)

{

customerID =id;

}

/**

Using this method can get the information of name and customerID.

@param none this method takes no argument

@return the information of name and customerID

*/

public String toString()

{

return "name is " + name + ", customerID is " + customerID;

}

/**

When creating an new object,if no arguments provided, using this constructor to initialize it.

@param none this method takes no argument

@return this method doesn't return anything

*/

public Customer(){

name = "";

customerID = 0;

}

/**

When creating an new object,this constructor initializes the name and customer's ID using the arguments

@param name initializes name

@param id initializes customerID

@return this method doesn't return anything

*/

public Customer(String name, int id)

{

setName(name);

setID(id);

}

/**

When creating an new object,initializing name and customer's ID copying the data of other customer object

@param customer a variable that represents the account owner, including information of name and ID

@return this method doesn't return anything.

*/

public Customer(Customer otherCustomer)

{

name = new String(otherCustomer.name);

customerID = otherCustomer.customerID;

}

}

-----------------------------------------------------------------------------------------------------------------------------------

/**

create a class called BankAccount

*/

public class BankAccount{

private double balance, overdraftAmount = 100.0;

private Customer customer;

/**

using this method can add balance

@param amount amount of deposit

@return this method doesn't return anything

*/

public void deposit(double amount){

if (amount >= 0.0)

this.balance += amount;

}

/**

using this method can decrease balance

@param amount amount of withdraw

@return this method doesn't return anything

*/

public void withdraw(double amount){

if (this.balance - amount >= -overdraftAmount && amount >= 0.0)

this.balance -= amount;

}

/**

using this method can access balance

@param none this method takes no argument

@return balance

*/

public double getBalance(){

return this.balance;

}

/**

using this method can update overdraftAmount

@param amount amount of overdraftAmount

@return this method doesn't return anything

*/

public void setOverdraftAmount(double amount){

this.overdraftAmount = amount;

}

/**

using this method can access customer

@param none this method takes no argument

@return customer

*/

public Customer getCustomer(){

return customer;

}

/**

when creating an new object,this constructor initializes the balance and overdraftAmount

@param none this method takes no argument

@return this method doesn't return anything

*/

public BankAccount(){

balance = 0.0;

overdraftAmount = 100.0;

customer = new Customer();

}

/**

when creating an new object, this constructor initializes customer

@param initialCustomer initializes customer

@return this method doesn't return anything

*/

public BankAccount(Customer initialCustomer){

this.customer = new Customer(initialCustomer);

}

/**

when creating an new object, this constructor initializes customer and balance

@param initialCustomer intializes customer

@param initialbalance initializes balance

@return this method doesn't return anything

*/

public BankAccount(Customer initialCustomer, double initialbalance){

this.customer = new Customer(initialCustomer);

this.balance = initialbalance;

}

/**

when creating an new object, this constructor initializes balance

@param initialbalance initializes balance

@return this method doesn't return anything

*/

public BankAccount(double initialBalance){

customer = new Customer();

if (initialBalance >= 0.0)

balance = initialBalance;

}

}

Your first task is to ensure that the following classes from Assignment 4 are fully functional . BankAccount SavingsAccount . Customer Please use the provided test cases below to test the functionality of these classes before proceeding - note that there are additional test cases against which your code must run Next, create a setter method getCustomer) for the BankAccount class Now, create a new class BankApplication, which is a subclass of javafx.application.Application It should contain the following Instance Variables Customer (give the customer a name and an account ID) SavingsAccount (starting balance of $150.00, and the customer you have created as an instance variable) . The following GUI controls: o Labels: customerNameLabel, customerlDLabel, balanceLabel o Text fields: depositTextField, withdrawTextField Button: executeButton They should be laid out as follows Bank application ustomer name: Charles Brown count ID: 123456 Amt to deposit Execute urrent balance: $150.00. Amt to withdraw Each label and button should be on its own line, but the text fields should be next to each other Hints: Recall that you can add one Group (such as a Hbox) to another Group (such as a VBox) TextFields can be initialized by calling the setPromptText) method)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions

Question

=+" Is the guilt relevant to the issue?

Answered: 1 week ago

Question

love of humour, often as a device to lighten the occasion;

Answered: 1 week ago

Question

orderliness, patience and seeing a task through;

Answered: 1 week ago

Question

well defined status and roles (class distinctions);

Answered: 1 week ago