Project Name: Bank Account Management System bank account management system
Exercise based object-oriented syntax :( 1)
to write a class account (the Account), attribute:
id: Integer account number, the user's account (id) is generated automatically, the initial value of 100,000, a first account user id as 100001, 100002 for the second, and so on.
password: password string
name: Your real name string
open: the date of opening a date
balance: account balance double
Constructor:
There are no arguments and parameters, there are methods for setting configuration parameters necessary properties
Methods:
Deposit: deposit method parameter type is double the amount
withdraw: withdrawal method parameter type is double the amount
Exercise package :( 2)
the Account class is made completely encapsulated
Exercise 3 :( inherited)
bank's customers fall into two categories,
savings accounts (SavingAccount) and credit accounts (CreditAccount),
the difference is that savings accounts do not allow overdrafts, and credit accounts can be overdrawn, overdraft refers to the account balance is less than 0, and allows users to set their overdraft limit.
Note: CreditAccount need one more attribute ceiling overdraft facility
for both user-written related classes
Bank also requires the preparation of classes, attributes:
Constant: Final public int MAX_ACCOUNTS = 100000;
1. All accounts current array objects
2. Current Account Number
Method:
1. User Account: Account Type: 1 savings account 2. credit account, password, password confirmation, name, date as the computer automatically get the account opening date, returns the newly created Account object,
2. User login parameters: id password Account object is returned
In addition, add several statistical methods for the Bank class
1. All statistics the total number of bank account balances
2. Total number of statistics for all credit account overdraft
3. The Bank made a singleton class
Exercise 4 :( language advanced features abstract class)
for the Account class, there are two methods, methods deposit and withdrawal methods, please modify these two methods.
1. deposit method was changed to not allow subclasses to modify
2. The method according to different withdrawal different subclass (credit account overdraft withdrawals), and therefore, to abstract methods are implemented in two subclasses
Bank several methods to add the class
1 user deposits parameters: ID, the amount of the deposit, return the modified Account object
2. The user dispensing parameters: ID, amount of withdrawal, return the modified Account object
3. Modify the overdraft limit, parameters: id, the new amount, return the modified account object. this method need to verify that the account is a credit account
Exercise 5 :( Interface)
is a SavingAccount and CreditAccount add each subclass
LoanSavingAccount categories: users can borrow, not overdraft
LoanCreditAccount class: Users can loans, overdraft
Description: loans and overdrafts are not the same, overdraft refers to the account balance is less than 0, and the loan users need to attribute a loan amount.
In the ATM machine, the user can select a loan, you can also choose to repay the loan, but the loan is to bring funds on the account balance to the loan amount, the loan can not be overdrawn
example: user balance of 10,000 yuan, 100,000 yuan loan amount, the user can choose the repayment 5,000 yuan, the user turns the balance of 5000, the loan amount becomes 95,000 yuan.
Use interfaces and abstract classes common LoanSavingAccount LoanCreditAccount class, LoanAccount interfaces
interface methods:
1.requestLoan: Loan
2.payLoan: repayment
3.getLoan: users get total loans
Add three methods for the Bank class,
1. Loans: parameter id, loan amount, return the modified Account object
2. loan: parameter id, payments, returns the modified Account object
total loans of all accounts 3. Statistics
4. modify the method accounts (savings accounts 3. loans 4. Loan credit account)
Code details:
GitHub address