Package src
Class Customer
java.lang.Object
src.Person
src.Customer
The Customer class represents a customer with multiple accounts.
It extends the Person class and provides functionality to manage
accounts, such as deposits, withdrawals, transfers, and viewing balances.
-
Constructor Summary
ConstructorsConstructorDescriptionCustomer()Default constructor for the Customer class.Customer(Dictionary<String, Account> accounts, int id, String firstName, String lastName, String dob, String address, String phone, int creditScore, int password) Constructs a Customer with specified account information and personal details. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTransactionEntry(String entry) booleandeposit(int accountNumber, double amount) Deposits or withdraws money into/from the specified account based on the account number.booleanDeposits or withdraws money into/from the specified account.findAccountType(int number) Finds the type of account based on the account number.Returns the customer's accounts.intReturns the balance of the desired account.intgetBalance(String accountType) Returns the balance of the account of the specified type.intReturns the customer's credit score.intgetId()Returns the customer's unique ID.intReturns the customer's password.Returns the customer's transaction logs.booleanTransfers a payment from one account of the current customer to another account of a different customer.booleanTransfers a payment from the current customer's account to another account belonging to a different customer.voidsetAccounts(Dictionary<String, Account> accounts) Sets the customer's accounts.voidsetCreditScore(int creditScore) Sets the customer's credit score.voidsetId(int id) Sets the customer's unique ID.voidsetPassword(int password) Sets the customer's password.voidsetTransactions(Transaction transactions) Sets the customer's transactions log so that entries can be added.booleantransfer(int source, int dest, double amount) Transfers money from one account to another within the same customer.booleanTransfers money from one account to another within the same customer.booleanwithdraw(int accountNumber, double amount) Withdraws money from the specified account based on the account number.booleanWithdraws money from the specified account.Methods inherited from class src.Person
getAddress, getDOB, getFirstName, getLastName, getName, getPhoneNumber, setAddress, setDOB, setFirstName, setLastName, setPhoneNumber, toString
-
Constructor Details
-
Customer
public Customer()Default constructor for the Customer class. Initializes an empty hashtable of accounts and sets the id to -1. -
Customer
public Customer(Dictionary<String, Account> accounts, int id, String firstName, String lastName, String dob, String address, String phone, int creditScore, int password) Constructs a Customer with specified account information and personal details.- Parameters:
accounts- The dictionary of the customer's accounts.id- The unique ID of the customer.firstName- The customer's first name.lastName- The customer's last name.dob- The customer's date of birth.address- The customer's address.phone- The customer's phone number.
-
-
Method Details
-
setAccounts
Sets the customer's accounts.- Parameters:
accounts- The dictionary of the customer's accounts.
-
setId
public void setId(int id) Sets the customer's unique ID.- Parameters:
id- The unique ID of the customer.
-
setCreditScore
public void setCreditScore(int creditScore) Sets the customer's credit score.- Parameters:
creditScore- The credit score of the customer.
-
setTransactions
Sets the customer's transactions log so that entries can be added.- Parameters:
transactions- The object that will store the transaction logs.
-
setPassword
public void setPassword(int password) Sets the customer's password.- Parameters:
password- The password for the customer.
-
getAccounts
Returns the customer's accounts.- Returns:
- A dictionary of the customer's accounts.
-
getId
public int getId()Returns the customer's unique ID.- Returns:
- The unique ID of the customer.
-
getPassword
public int getPassword()Returns the customer's password.- Returns:
- The password of the customer.
-
getCreditScore
public int getCreditScore()Returns the customer's credit score.- Returns:
- The credit score of the customer.
-
getTransactions
Returns the customer's transaction logs.- Returns:
- The object storing the customers transaction logs.
-
addTransactionEntry
-
findAccountType
Finds the type of account based on the account number.- Parameters:
number- The account number to find.- Returns:
- The type of the account as a string, or null if not found.
-
getBalance
public int getBalance()Returns the balance of the desired account. If the customer has more than one account, it prompts the user for the account type or number.- Returns:
- The balance of the specified account or -1, -2, -3 for exit codes.
-
getBalance
Returns the balance of the account of the specified type.- Parameters:
accountType- The type of the account.- Returns:
- The balance of the account.
-
deposit
Deposits or withdraws money into/from the specified account.- Parameters:
accountType- The type of the account.amount- The amount to deposit (positive) or withdraw (negative).- Returns:
- true if the transaction was successful, false otherwise.
-
deposit
public boolean deposit(int accountNumber, double amount) Deposits or withdraws money into/from the specified account based on the account number.- Parameters:
accountNumber- The account number.amount- The amount to deposit or withdraw.- Returns:
- true if the transaction was successful, false otherwise.
-
withdraw
Withdraws money from the specified account.- Parameters:
accountType- The type of the account.amount- The amount to withdraw.- Returns:
- true if successful, false otherwise.
-
withdraw
public boolean withdraw(int accountNumber, double amount) Withdraws money from the specified account based on the account number.- Parameters:
accountNumber- The account number.amount- The amount to withdraw.- Returns:
- true if successful, false otherwise.
-
transfer
public boolean transfer(int source, int dest, double amount) Transfers money from one account to another within the same customer.- Parameters:
source- The source account number.dest- The destination account number.amount- The amount to be transferred.- Returns:
- true if successful, false otherwise.
-
transfer
Transfers money from one account to another within the same customer.- Parameters:
source- The source account type.dest- The destination account type.amount- The amount to be transferred.- Returns:
- true if successful, false otherwise.
-
pay
Transfers a payment from one account of the current customer to another account of a different customer.- Parameters:
customer- The customer who will receive the payment.source- The source account number of the current customer.dest- The destination account number of the receiving customer.amount- The amount to be transferred.- Returns:
- true if the payment was successful, false otherwise.
-
pay
Transfers a payment from the current customer's account to another account belonging to a different customer.- Parameters:
customer- The customer receiving the payment.source- The type of the source account (e.g., "checking", "saving") from which the payment will be made.dest- The type of the destination account (e.g., "checking", "saving") to which the payment will be transferred.amount- The amount to be transferred.- Returns:
- true if the payment was successful, false otherwise.
-