Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Program: bankprojectgroup3
- * This Account.java
- * Date:1/27/2016
- * Author: Nicholas Johnston, Tim Ryan, Brice Habets, Thomas Kweram
- * Purpose: To hold balances, the names of account holders, and savings checking
- and debt
- Possess methods for changing these values in response to the Menu.java class
- */
- package bankprojectgroup3;
- //==========================================class body: ==========================
- public class Account {
- //=====Class member variables=====================================
- private double checking;
- private double savings;
- private double debt;
- private String name;
- //==================Defualt constructor===========================
- public Account()
- {// This is the default value of the Account object
- this.checking = 0;
- this.savings =0;
- this.debt = 0;
- this.name = "If you are reading this, this is invalid";
- }
- //=====================Parameterized contructor================
- public Account(double checking, double savings, double debt, String name)
- {
- this.checking = checking;
- this.savings = savings;
- this.debt = debt;
- this.name = name;
- }
- //====================account methods===============================
- // =============allows user to choose which account to deposit in===
- public double deposit(int choice,double amount)
- { //This method adds money to an account, the value of choice chooses which
- //and the value of amount signifies how much
- switch(choice)
- {
- case 1:
- //checking
- this.checking =this.checking + amount;
- return this.checking;
- case 2:
- //savings
- this.savings = this.savings + amount;
- return this.savings;
- case 3:
- //debt, the method is inverted and decreases the debt
- this.debt = this.debt - amount;
- return this.debt;
- default:
- //Validator
- System.out.println("Error: There is something"
- + " wrong with the menu");
- break;
- }
- return 0;
- }
- //=====allows user to choose which account to withdraw money from=======
- public double withdraw(int choice, double amount)
- {//removes money in the case of checking and savings
- //increases if called on the debt account
- switch(choice)
- {
- case 1:
- //checking
- this.checking = this.checking - amount;
- return this.checking;
- case 2:
- //savings
- this.savings = this.savings - amount;
- return this.savings;
- case 3:
- //debt
- this.debt = this.debt + amount;
- return this.debt;
- default:
- //Validator
- System.out.println("Error: There is something "
- + "wrong with the menu");
- break;
- }
- return 0;
- }
- //============allows user to choose which account to view the balance of===
- public double viewAccount(int choice)
- {// this returns the value of an account for use by the menu object
- switch(choice)
- {
- case 1:
- //checking
- return this.checking;
- case 2:
- //savings
- return this.savings;
- case 3:
- //debt
- return this.debt;
- default:
- //Validator
- //This should never be called
- System.out.println("Error: There is something "
- + "wrong with the menu");
- break;
- }
- //this should never be returned
- return 0;
- }
- public String getAccountType(int selection)
- {//This returns the name of the account, it is used in the menu object to
- // tell the user which account the transaction has been aapplied too
- switch(selection)
- {
- case 1:
- {//checkings
- return "Checking";
- }
- case 2:
- {//savings
- return "Savings";
- }
- case 3:
- {//Debt
- return "Debt";
- }
- default:
- {//This should never be chosen, the validator will ensure this
- return "Invalid choice";
- }
- }
- }
- //======================getter setter block========================
- //========================Checking=================================
- public double getChecking() {
- return checking;
- }
- public void setChecking(double checking) {
- this.checking = checking;
- }
- //=========================savings=======================================
- public double getSavings() {
- return savings;
- }
- public void setSavings(double savings) {
- this.savings = savings;
- }
- //======================Debt==============================================
- public double getDebt() {
- return debt;
- }
- public void setDebt(double debt) {
- this.debt = debt;
- }
- //===============Name====================================================
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- //============end of getter setter block====================================
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement