• Post Reply Bookmark Topic Watch Topic
  • New Topic

ATM Class  RSS feed

 
Kristina Hawkins
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

I'm writing a simple code for ATM, but as I have never worked with a user's input, I'm not sure where to start.
I have written 3 classes








Now I have to write a call where everything runs:


displayAccountInformation()
Displays a BankCustomer's account information if the customer has been previously verified.
void
initialize()
Adds Customer references to the Back HashMap as seed data for testing.
static void
main(java.lang.String[] args)
Main method calls the class default constructor.
void
run()
The primary application processor.
void
transactDeposit()
Performs a deposit into a BankCustomer's account.
void
transactWithdraw()
Performs a withdrawal from a BankCustomer's account.
void
verifyCustomer()
To confirm a BankCustomer's account number and passcode


and these are all methods that I have to use.

Thank you!
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fantastic job with the formatting of your code! The classes appear to be well thought out and organized, too. Now as for how you'd tie everything together you might want to create another class, say an ATM class, to represent a bank customer's access point to the services of the bank that will be provided in some way by the classes you have defined. Don't take some of those instructions literally though because some of those method names mentioned in the instructions are not the same exact names you've used in your code; go by the intent because it's pretty easy to tell which one you really want to call. Go get user input, well, you already have written a class to handle that so all you have to do is call an appropriate method of that class.
 
Kristina Hawkins
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Kristina Hawkins
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! This is what I have do far on my ATM class
 
Kristina Hawkins
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also have to use initialize () method to add customers to HashMap, not sure what to do here

and seems that my withdraw/deposit methods don't work properly too.

Any help or tips would be greatly appreciated!!!
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks great.  But why are you doing this 
       
multiple times?  Will it not be better if you create multiple BankCustomer objects and maintain a map where account number is the key and the object is the value, and ideally your verify or other helper methods should also change.  you should first check whether the account number exists or not in the map, if exists the proceed with further operations.
 
Kristina Hawkins
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's where I'm stuck. I don't know how to do it
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't read your code well enough to be sure the Map is the best way to implement things, but Maps have all sorts of methods to find the sort of numbers you want. Start with the Java™ Tutorials.
By the way: Is “theBank” the best name for a Map?
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kristina, you have to look past the technical/mechanical aspects of the instructions and understand the intent.  This will give you the context; that's what you're missing and that's why you're confused.  It's like somebody is telling you to "Jump three feet to your left! Right now!" and you're standing there looking confused.  If they had yelled out instead, "You're about to get hit by a bus!" then you'd have the proper context to do what you needed to do.

The instruction to "use initialize() method to add customers to HashMap" is like just telling you to jump three feet to your left. The intent is for you to create a Bank and set it up with a few BankCustomers so that the ATM can behave like a real ATM that can service multiple customers.

So, your ATM should be associated with a Bank which keeps information about which BankCustomers it has who keep their money at the Bank.

Now, think back to your own experience with ATMs.  You walk up, put your bank card in, enter your PIN, and then do things like withdraw, deposit, check balance, etc.  When you're done, your ATM session ends and the next person in line can come up and take his/her turn doing things at the ATM, except whatever that person does will pertain to their bank account, not yours.

Does this give you a better idea of what the ATM is supposed to do with its associated Bank object and that Bank object's associated BankCustomer objects?

Try to implement just one ATM function first, like logging in. So when there's no active BankCustomer using the ATM, it should just display something like: "Please enter your Account # to start:", then when the user enters that, they'd be prompted to "Please enter your PIN:" ...

I'll leave it to you to think through how the rest of that interaction would go.
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few more things to clarify the intent of that initialize() method.  The reason for this method is to keep things simple. A real ATM doesn't get initialized with a Bank object and a few BankCustomers. A real ATM would be connected remotely to an application that's running in the bank's data center where all the information about bank customers are kept in huge databases that can hand thousands of simultaneous requests from multiple ATM machines.  Your program is only a small simulation that isn't actually connected to anything else. So, you have to somehow simulate the ATM reaching across a network and doing a bunch of complicated things to request information and submit transaction requests on behalf of the customer.

The initialize() method that you're supposed to write sets up that little simulated environment where you have a Bank that an ATM can go to and ask about customer account information or tell the Bank that the customer who's using the ATM just made a withdrawal or deposit or what not.

Does that make sense?
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may have a look on the following code.  It's the same what you have with few minor changes.

[Moderator edit: Please give OP a chance to do her own homework and come up with her own solution first. Thanks.]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!