代写C++代码 代做C++程序 C++辅导 C++教学

C++网络家教 远程写代码 在线Debug 讲解答疑 不是中介,本人直接写

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

CSE 17

Program Files (8):  AtmTransaction.java, BankAccount.java, CheckingAccount.java, 

CheckTransaction.java, DepositTransaction.java, FeeTransaction.java, 

Transaction.java, WithdrawalTransaction.java 

For this assignment, you will write a program to support the tracking of a checking account. This program 

emphasizes various aspects of inheritance, abstract classes and interfaces. The details of each class are 

given in UML form below. We will test your program by writing a main method that depends on this 

contract exactly as specified below. Therefore, it is essential that the class names and the methods (names, 

return types and parameter lists) appear exactly as described.  Note, that Date below always refers to 

java.util.Date. 

BankAccount   

-accountNum:int  The account number 

-customerName:String  The customer’s full name 

-balance:double 

#transactions:ArrayList 

The account balance, in dollars and cents 

ArrayList of all Transactions against this account 

#balanceHistory:ArrayList  ArrayList containing account balance after each 

transaction. 

+BankAccount(accountNum:int, 

customerName:String, balance:double) 

Initialize a new bank account using the parameters.  

+BankAccount(accountNum:int, 

customerName:String) 

Initialize a new bank account , setting the balance to 0. 

+getAccountNum():int  Get method for accountNum 

+getCustomerName():String  Get method for customerName 

+getBalance():double  Get method for balance 

+addTransaction(t:Transaction):void  Adds t to the end of transactions and then applies it to the 

account. Records new balance in balanceHistory 

deposit(value:double):void  If the value > 0 then adds it to the account’s balance 

withdraw(value:double):void  If the value > 0 then subtracts it from the account’s 

balance 

+printStatement(startDate:Date, 

endDate:Date):void 

Writes an account statement to the screen for all 

transactions that occur between startDate and endDate 

inclusive. See below for the expected format of the 

account statement.  

+toString():String  Returns the account’s number and balance. 

+getAccountType():String  Returns the account type. 

 

CheckingAccount  A subclass of BankAccount 

-insufficientFundsFee:double  Fee to withdraw from an account if funds are insufficient 

to cover a check. Initially 30.0. 

+CheckingAccount(accountNum:int, 

customerName:String, balance:double) 

Initialize a new checking account using the parameters. 

+getAccountType():String  Returns “Checking” 

+getInsufficentFundsFee():double  Get method for insufficientFundsFee 

+setInsufficientFundsFee(fee: double):void  Set method for insufficientFundsFee 

 CSE 17, Fall 2014 

 

 

Transaction  An activity that changes the balance of a bank 

account. 

-transactionDate:Date  Date of the transaction 

-amount:double  Amount of the transaction in dollars and cents. 

#Transaction( transactionDate:Date, amount:double)  Initializes the object 

+getDescription():String   Returns a description for the transaction. See 

subclasses for values. 

+getTransactionDate():Date  Returns the transaction date 

+getAmount():double  Returns the amount of the transaction. 

+toStatementRow():String  Returns a string containing the transaction 

information in row form. This will be used by 

printStatement() in the bank accounts. 

+execute(account:BankAccount):void   Applies the transaction against account. 

 

WithdrawalTransaction  A subclass of Transaction 

   

+WithdrawalTransaction(transactionDate:Date, 

amount:double) 

Initializes the object. Note, amounts are expected 

to be positive numbers 

+getDescription():String  Returns “Withdrawal” 

+execute(account:BankAccount):void   Subtracts the transaction amount from the 

account 

+toStatementRow():String  Should return a string of the format: “date 

description amount” where the date is given 

10 characters, the description 30 characters, 

and the amount 10 characters. See “Account 

Statement Format” below for examples. 

 

DepositTransaction   A subclass of Transaction 

-description:String  A description of the deposit 

+DepositTransaction(transactionDate:Date, 

amount:double, description:String) 

Initializes the object 

+getDescription():String   Return description 

+execute(account:BankAccount):void   Adds the transaction amount into the account 

+toStatementRow():String  Should return a string of the format: “date 

description amount” where the date is given 10 

characters, the description 30 characters, then 

there are 10 blank spaces, followed by the 

amount given in 10 characters. See “Account 

Statement Format” below for examples. 

 

AtmTransaction   A subclass of WithdrawalTransaction 

-address:String  The address of ATM where money was withdrawn 

+AtmTransaction(transactionDate:Date, 

amount:double, address:String) 

Initializes the object 

+getDescription():String   Returns “ATM - address” 

 

FeeTransaction   A subclass of WithdrawalTransaction 

-justification:String   

+FeeTransaction(transactionDate:Date, 

amount:double, justification:String)  

Initializes the object 

+getDescription():String   Returns justification CSE 17, Fall 2014 

 

 

 

CheckTransaction  A subclass of WithdrawalTransaction 

-payee:String   The name of the entity the check is made out to 

-checkNo:int   The check number 

+CheckTransaction(transactionDate:Date, 

amount:double, payee:String, checkNo:int) 

Initializes the object 

+getDescription():String   Returns “Check checkNo - payee” 

+getPayee():String   Returns the payee 

+getCheckNo():int   Returns the checkNo 

+compareTo(Object:o):int  Returns < 0 if this checkNo is < that of o. Returns 

0 if they are equal. Otherwise, returns > 0. 

+execute(account:BankAccount):void   Execute a withdrawal for the check amount from 

the account. If the resulting balance of the 

account is less than 0, generates a 

FeeTransaction with the current date, 

justification “Overdraft fee”, and amount 

specified by the insufficientFundsFee 

variable, and applies the transaction to the 

account. 

 

Account Statement Format: 

The printStatement method for a BankAccount should first print identifying information about the 

account and then a list of transactions. All monetary amounts should be formatted to display two decimal 

places, and dates should be printed in “mm/dd/yyyy” format. For example, a statement with start date 

9/1/2014 and end date 9/30/2014 might looks like: 

 

Account Holder:  John Doe 

Account Number:   9999 

Statement Period:  09/01/2014 to 09/30/2014 

Starting Balance:  $5000.00 

Ending Balance:  $5775.01 

 

Date  Description  Withdrawal  Deposit  Balance 

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

09/01/2014  Check 101 – Publix      125.00       4875.00 

09/02/2014  ATM -1880 FL 44, New Smyrna, FL      200.00       4675.00 

09/02/2014  ATM Fee        4.00       4671.00 

09/10/2014  Check 103 – PPL       96.00       4575.00 

09/12/2014 Payroll Deposit       1200.00    5775.00 

09/18/2014  Check 102 – RCN       99.99       5675.01 

09/24/2014  Check 104 – Morty’s Mortgage     1100.00       4575.01 

09/26/2014 Payroll Deposit       1200.00    5775.01 

 

In this example, we assume that 8 transactions have been applied to the account in the statement period. 

The first, fourth, sixth and seventh are all CheckTransactions.  The second is an AtmTransaction, the 

third is a FeeTransaction (with justification “ATM Fee”), and the fifth and eighth are 

DepositTransactions (with description “Payroll Depoist”). Each row of the statement is printed using the 

toStatementRow()  method. followed by the balance of the account after that transaction was applied.  

Note that the date is formatted to 10 characters, the description 30 characters, and withdrawal, deposit and 

balance are all formatted to 10 characters total, with two digits after the decimal point. The form of the 

description varies depending on what kinds of transaction it is, so it is important that the 

toStatementRow() methods use the dynamically bound getDescription() method. 

 CSE 17, Fall 2014 

 

 

Hints: 

•  String has a format() method that works just like printf(), except that the result is returned as a 

string instead of printed to the screen (or file). You can use this to ensure that strings produced by 

toStatementRow() are formatted so that they will print in nice columns. 

•  You can use the java.text.SimpleDateFormat class to create an object capable of formatting any 

date in a desired way. Use the parameter “MM/dd/yyyy” to specify the format used for dates in 

this assignment. The instance method +format(date:Date):String will produce a corresponding 

string in the desired format. For testing, you may want to use the +parse (source:String) method 

to create new Date objects from a string in the human-readable form.  

•  The balanceHistory field can be useful when printing statements. Be sure to update it correctly. 

•  Your program is meant to be used by a client program to manage one or more checking accounts. 

As such, I do not tell you to write a main method. However, the only way you can be sure your 

program works is to do so. I suggest you write one that create multiple checking accounts and 

applies multiple transactions of each kind against it. At a minimum, print some account 

statements with a few different date ranges. Ideally, you should test each method and anything 

that might trigger a different condition. You can assume that the main method we write to test 

your program will do so. 

 

Comments: 

At a minimum provide a Javadoc comment explaining what each method does, and another one that 

summarizes the class. Include additional comments for lines that are especially complicated. At the top of 

each file, include a comment with the following form: 

 


Submission: 

Once the program compiles, runs, and has been tested to your satisfaction, use SSH to connect to your 

account on sunlab.cse.lehigh.edu. Create a subdirectory of cse017.144 called P3 and transfer all eight 

.java files to this subdirectory (~/cse017.144/P3/ where ~ represents your home directory). Be very 

careful to ensure that you have spelled the directories correctly and used the correct case for all letters in 

directory and file names. At the time of the deadline, an email will be sent to you either confirming that 

your files have been collected or stating that the files have not been collected.  


相关推荐