Question
1. Transaction Write a fully-documented class named Transaction which contains the date (String), amount (double) , and description (String). You should provide accessor methods for
1. Transaction
Write a fully-documented class named Transaction which contains the date (String), amount (double) , and description (String). You should provide accessor methods for each variable, but no mutator methods. This is because a transaction should never be modified after being created. The full list of required methods is:
- public Transaction - Constructor (you may include a constructor with parameters)
- Getter methods for each variable
- public Object clone() - The return value is a copy of this Transaction. Subsequent changes to the copy will not affect the original and vice versa. Note that the return value must be typecasted to a Transaction before it can be used. Note that the copy being returned must be a deep copy.
- public boolean equals(Object obj) - A return value of true indicates that obj refers to a Transaction object with the same attributes as this Transaction. Otherwise, the return value is false.
You will also need the following variables:
- String date
- double amount
- String description
2. GeneralLedger
Write a fully-documented class named GeneralLedger that stores an ordered list of transaction objects within an array. The array indices determine the order the transactions are to be posted. An accountant can insert a transaction at any position within the range of the list. The GeneralLedger can record a total of 50 transactions, so use the static final variable int MAX_TRANSACTIONS = 50 (and refrain from using the number 50 within your code). Additionally, create variables of type double "totalDebitAmount" and "totalCreditAmount" to keep track of the running total of all debit and credit amounts for all transactions. These variables should be modified every time a transaction is added or deleted from the general ledger. For example, if Jason's general ledger is empty, "totalDebitAmount" and "totalCreditAmount" should both be initialized to 0. After a single transaction is added with amount value 50, meaning $50 is debited to his account, the value of "totalDebitAmount" should now be 50 and "totalCreditAmount" should now be 0.
NOTE: Make sure there are no gaps between Transactions in the list.
NOTE: Note that arrays in Java are 0 indexed, but your listing preference should start from 1.
3. GeneralLedgerManager
Write a fully documented class named GeneralLedgerManager which will act as a driver for the ledger that is based on the following specification:
public class GeneralLedgerManager
- public static void main(String[] args)
- The main method runs a menu driven application which first creates an empty GeneralLedger object. The program prompts the user for a command to execute an operation. Once a command has been chosen, the program may ask the user for additional information if necessary and performs the operation. The operations should be defined as follows:
- A - Add Transaction
- Adds a new transaction into the ledger.
- G - Get Transaction
- Displays information of a Transaction at a given position.
- R - Remove Transaction
- Removes the transaction at the given position.
- P - Prints Transaction in General Ledger
- Displays all transaction in the General Ledger.
- F - Filter by Transaction Date
- Displays all transactions that were posted on the specified date.
- L - Look for Transaction
- Determines whether the transaction with the given attributes is in the current General Ledger.
- S - Size
- Determines the number of transactions in the General Ledger. (NOTE: This must complete in O(1) time.)
- B - Backup
- Creates a copy of the given General Ledger. Changes to the copy will not affect the original and vice versa.
- PB - Print Transactions in Backup
- Displays all the transactions in the backed-up copy.
- RB - Revert to Backup
- Reverts the current General Ledger to the backed-up copy.
- CB - Compare Backup with Current
- Compares the backed-up ledger with the current ledger.
- PF - Print Financial Information
- Displays the sum of all debit dollar amounts for all transactions side-by-side with the sum of all credit dollar amount of all transactions. Also prints the net worth value of the account, which is the result of subtracting the total credit amount from the debit amount. (NOTE: This must complete in O(1) time.)
- Q - Quit
- Terminates the program.
- A - Add Transaction
- The main method runs a menu driven application which first creates an empty GeneralLedger object. The program prompts the user for a command to execute an operation. Once a command has been chosen, the program may ask the user for additional information if necessary and performs the operation. The operations should be defined as follows:
4. You will need classes to handle the exceptions thrown (see class specifications above for exception classes you need).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started