vendredi 6 mars 2015

Java banking application program [on hold]



I am very confused about my project. My code makes a menu and it works as a banking app very well. Problem is it does not meet many requirements of the project. Im supposed to have multiple methods and classes. Im not aware of how to call them to run in one program and the same goes with methods.



package bank;

import java.util.Scanner;


// change Account class

public class bank {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

int menu;

boolean quit = false;

float balance = 0f;

do {

System.out.println("1. Deposit money");

System.out.println("2. Withdraw money");

System.out.println("3. Check customers balance");

System.out.print("Your choice, 0 to quit: ");

menu = in.nextInt();

switch (menu) {

case 1:

float amount;

System.out.print("Amount to deposit: ");

amount = in.nextFloat();

if (amount <= 0)

System.out.println("invalid cant deposit 0");

else {

balance += amount;

System.out.println("$" + amount + " has been deposited.");

}

break;

case 2:

System.out.print("Amount to withdraw: ");

amount = in.nextFloat();

if (amount <= 0 || amount > balance)
//remeber to place in method
System.out.println("invalid");

else if (amount >= 1000 || amount > balance){

System.out.print("you can not withdraw more than $1000");
}


else {

balance -= amount;

System.out.println("$" + amount + " has been withdrawn.");

}

break;

case 3:

System.out.println("Your balance: $" + balance);

break;

case 0:

quit = true;

break;

default:

System.out.println("Wrong choice.");

break;

}

System.out.println();

} while (!quit);

System.out.println("Program quits");

}

}


INSTRUCTIONS Account class:

• Add a maxWithdrawal field member and set it to 1000;

• Add a transactionCount field member to keep track of the amount of

transactions for the account.

• Constructor(s)

All information required for an account creation must be initialized in the constructor. An account number must also be assigned in the constructor (generated by the AccountSupport class’ static method getAccountNumber())

• Deposit method

This method needs to accept an appropriate deposit amount. Validate the

amount being received and if valid, send it to another method that will update the balance. Once the balance has been updated, return a boolean value to the calling point of the method.


• Withdraw method

This method needs to accept an appropriate withdraw amount. Validate the amount being received and if valid, send it to another method that will update the balance. Once the balance has been updated, return a boolean value to the calling point of the method.


• Update balance method

This method will be a method with internal class access only. This method

will accept an amount to be deposited or withdrawn from the account balance. Proper validation of the balance change must be in place (i.e. if there is not enough money in the account or if a withdrawal is beyond the allowed amount).


• Transaction count method

This method will return the amount of transactions for the account.


• Other methods

The Account class also needs to be able to return the following information:

o balance information

o account number/id


Customer Class


The customer class needs to:

o Have a reference to an Account object

o Have a field variable that keeps track of the amount of accounts a

customer has. (Max 2 accounts allowed)

o A default constructor as well as a constructor that initializes all user-­‐ provided customer data.

o Create an Account automatically when a customer is created and add

it to an ArrayList that can hold objects of Account type

o Accessor and mutator methods for all customer data

o A method to create additional accounts unless the max amount of

accounts have been met


Account Support Class

This class only supports the Account class with a single functionality: provide an account number when an Account object is created. No objects needs to be created from this class


Teller Class

This is the class that has be main() method in it. Teller will have an ArrayList with customers in it; once a customer is created it must be stored in the list. From this class, a menu driven interface must allow for:

o creation of a new customer Adding all customer attributes (i.e. names etc).Adding Account information


Bonus opportunity:

o lookup of a customer

Display all the information of a customer (including account

info) managing all customer attributes (i.e. change names etc). add more accounts (if applicable)

deposit and withdraw money from an account




Aucun commentaire:

Enregistrer un commentaire