In this phase you’ll be writing code within the methods of your classes to make the tests pass. Account Each account should have a constant, unique id. Id numbers should start from 1000 and increment by 5. The ACCOUNT_ID attribute should be initialised when the account object is created. The id should be generated internally within the class, it should not be passed in as an argument. The deposit method should increase the balance by the value passed in as an argument. The withdraw method should reduce the balance by the value passed in as an argument. It should return the value of the argument The account should be able to go overdrawn The correctBalance method should change the balance to match the value passed in as an argument. Testing your code for Account Run TestAccountInitialisation to check that the ID has been set correctly. Run TestAccountMethods to check that all of the methods work. Customer Each customer should have a constant, unique id. Id numbers should start from 2000000 and increment by 7. The CUSTOMER_ID attribute should be initialised when the account object is created. The id should be generated internally within the class, it should not be passed in as an argument. The customer’s name and address should be set when the customer object is created. The addAccount() method should take an account object as an argument and add it to the list of accounts stored within the customer. The removeAccount() method should take an account object as an argument and remove it from the list of accounts stored within the customer. Testing your code for Customer Run TestCustomerInitialisation to check that id has been set correctly. Run TestCustomerMethods to check that the addAccount() and removeAccount() methods work and that the name and address have been set correctly. SavingsAccount It should not be possible for the savings account to go overdrawn. In the case that an amount larger than the balance is passed into the withdraw method, nothing should be subtracted from the balance and zero should be returned. The addInterest() method should calculate the interest due on the account and add it to the balance. The formula to calculate the interest due is balance * interest rate / 100. Testing your code for SavingsAccount Run TestSavingsAccount. CheckingAccount The getNextCheckNumber() method should return the value of the nextCheckNumber variable. The first check should have number 1. Each subsequent check number should count up by one. Testing your code for CheckingAccount Run TestCheckingAccount Person The chargeAllAccounts method should be implemented so that the amount passed in is subtracted from from the balance of each of the person’s accounts. Testing your code for Person Run TestPerson Company The chargeAllAccounts method should be implemented so that the amount passed in is subtracted from the balance of all of the company’s checking accounts. The amount subtracted from the balance of all of the company’s savings accounts should be doublethe amount passed in. Testing your code for Company Run TestCompany AccountController The createCustomer method takes a name, address and customer type as arguments. If the type is “person”, createCustomer should create a Person object with the correct name and address. It should add the Person object to the account controller’s list of Person objects. It should return the Person object. If the type is “company”, createCustomer should create a Company object with the correct name and address. It should add the Company object to the account controller’s list of Company objects. It should return the Company object. The createAccount method takes a Customer object and an account type as arguments. If the type is “checking”, createAccount should create a CheckingAccount object, add the object to accountController’s list of accounts and to the customer’s list of accounts. It should return the CheckingAccount object. If the type is “savings”, createAccount should create a SavingsAccount object, add the object to accountController’s list of accounts and to the customer’s list of accounts. It should return the SavingsAccount object. The removeAccount method takes an Account object as an argument. It should remove the account from the account controller’s list of accounts. It should remove the account from the customer’s list of accounts. The removeCustomer method takes a Customer object as an argument. It should remove the customer from the account controller’s list of customers. It should remove all of the customer’s accounts from the account controller’s list of accounts

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

JAVA QUESTION REQUIRES SEPARATE CLASSES, CANNOT BE WRITTEN IN ONE MAIN METHOD E.G. ACCOUNT SECTION WRITTEN IN ACCOUNT CLASS, CUSTOMER SECTION WRITTEN IN CUSTOMER CLASS ETC.

Phase 2

In this phase you’ll be writing code within the methods of your classes to make the tests pass.

Account

  • Each account should have a constant, unique id. Id numbers should start from 1000 and increment by 5. The ACCOUNT_ID attribute should be initialised when the account object is created. The id should be generated internally within the class, it should not be passed in as an argument.
  • The deposit method should increase the balance by the value passed in as an argument.
  • The withdraw method should reduce the balance by the value passed in as an argument. It should return the value of the argument
  • The account should be able to go overdrawn
  • The correctBalance method should change the balance to match the value passed in as an argument.

Testing your code for Account

  • Run TestAccountInitialisation to check that the ID has been set correctly.
  • Run TestAccountMethods to check that all of the methods work.

Customer

  • Each customer should have a constant, unique id. Id numbers should start from 2000000 and increment by 7. The CUSTOMER_ID attribute should be initialised when the account object is created. The id should be generated internally within the class, it should not be passed in as an argument.
  • The customer’s name and address should be set when the customer object is created.
  • The addAccount() method should take an account object as an argument and add it to the list of accounts stored within the customer.
  • The removeAccount() method should take an account object as an argument and remove it from the list of accounts stored within the customer.

Testing your code for Customer

  • Run TestCustomerInitialisation to check that id has been set correctly.
  • Run TestCustomerMethods to check that the addAccount() and removeAccount() methods work and that the name and address have been set correctly.

SavingsAccount

  • It should not be possible for the savings account to go overdrawn. In the case that an amount larger than the balance is passed into the withdraw method, nothing should be subtracted from the balance and zero should be returned.
  • The addInterest() method should calculate the interest due on the account and add it to the balance. The formula to calculate the interest due is balance * interest rate / 100.

Testing your code for SavingsAccount

  • Run TestSavingsAccount.

CheckingAccount

  • The getNextCheckNumber() method should return the value of the nextCheckNumber variable. The first check should have number 1. Each subsequent check number should count up by one.

Testing your code for CheckingAccount

  • Run TestCheckingAccount

Person

  • The chargeAllAccounts method should be implemented so that the amount passed in is subtracted from from the balance of each of the person’s accounts.

Testing your code for Person

  • Run TestPerson

Company

  • The chargeAllAccounts method should be implemented so that the amount passed in is subtracted from the balance of all of the company’s checking accounts. The amount subtracted from the balance of all of the company’s savings accounts should be doublethe amount passed in.

Testing your code for Company

  • Run TestCompany

AccountController

  • The createCustomer method takes a name, address and customer type as arguments.
    • If the type is “person”, createCustomer should create a Person object with the correct name and address. It should add the Person object to the account controller’s list of Person objects. It should return the Person object.
    • If the type is “company”, createCustomer should create a Company object with the correct name and address. It should add the Company object to the account controller’s list of Company objects. It should return the Company object.
  • The createAccount method takes a Customer object and an account type as arguments.
    • If the type is “checking”, createAccount should create a CheckingAccount object, add the object to accountController’s list of accounts and to the customer’s list of accounts. It should return the CheckingAccount object.
    • If the type is “savings”, createAccount should create a SavingsAccount object, add the object to accountController’s list of accounts and to the customer’s list of accounts. It should return the SavingsAccount object.
  • The removeAccount method takes an Account object as an argument.
    • It should remove the account from the account controller’s list of accounts.
    • It should remove the account from the customer’s list of accounts.
  • The removeCustomer method takes a Customer object as an argument.
    • It should remove the customer from the account controller’s list of customers.

It should remove all of the customer’s accounts from the account controller’s list of accounts.

UML
Note that the classes Account & Customer and the method chargeAllAccounts are all abstract.
AccountController
- customers : List<Customer>
accounts : List<Account>
+ createCustomer(name : String, address : String, type : String) : Customer
+ createAccount(customer : Customer, type : String) : Account
+ removeCustomer(customer : Customer) : void
+ removeAccount(account : Account) : void
+ getCustomers() : List<Customer>
+ getAccounts() : List<Account>
Account
Customer
- ACCOUNT_ID : long
nextAccountld : long
# balance : double
CUSTOMER_ID : long
nextCustomerld : long
name : String
address : String
Account()
+ withdraw(amount : double) : double
accounts : List<Account>
+ deposit(amount : double) void
+ Customer(name : String, address : String)
+ correctBalance(amount : double) : void
+ getACCOUNT_ID() : long
+ getBalance(0 : double
+ addAccount(account : Account) : void
+ removeAccount(account : account) : void
+ chargeAllAccounts (amount : double) : void
+ getAccounts() : List<Account>
+ getCUSTOMER_ID() : long
+ getName() : String
+ setName(name : String) : void
SavingsAccount
CheckingAccount
getAddress() : String
- interestRate : double
- nextCheckNumber : int
|+ setAddress(address : String) : void
+ addinterest() : void
+ getinterestRate() : double
+ setlnterestRate(rate : double) : void
+ getNextCheckNumber() : int
Person
Company
Transcribed Image Text:UML Note that the classes Account & Customer and the method chargeAllAccounts are all abstract. AccountController - customers : List<Customer> accounts : List<Account> + createCustomer(name : String, address : String, type : String) : Customer + createAccount(customer : Customer, type : String) : Account + removeCustomer(customer : Customer) : void + removeAccount(account : Account) : void + getCustomers() : List<Customer> + getAccounts() : List<Account> Account Customer - ACCOUNT_ID : long nextAccountld : long # balance : double CUSTOMER_ID : long nextCustomerld : long name : String address : String Account() + withdraw(amount : double) : double accounts : List<Account> + deposit(amount : double) void + Customer(name : String, address : String) + correctBalance(amount : double) : void + getACCOUNT_ID() : long + getBalance(0 : double + addAccount(account : Account) : void + removeAccount(account : account) : void + chargeAllAccounts (amount : double) : void + getAccounts() : List<Account> + getCUSTOMER_ID() : long + getName() : String + setName(name : String) : void SavingsAccount CheckingAccount getAddress() : String - interestRate : double - nextCheckNumber : int |+ setAddress(address : String) : void + addinterest() : void + getinterestRate() : double + setlnterestRate(rate : double) : void + getNextCheckNumber() : int Person Company
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education