Atm transaction program using class and object

atm transaction program using class and object

Hi guys this is the first time ive posted to this forum, and ive tried getting my answer by asking others and google, but what i'm after is to complete an assignment that is asking me to complete a program that basically works as an ATM machine.

The assignment has to include inheritance and four classes so what i have posted below doesnt work but it has the four classes. Also the program must have basic ATM functionality like being able to withdraw, deposit etc, but i can probably manage on my own. Any help would be appreciated or if you could steer me into the correct direction, i dont expect anything to give me the answers but any help would be greatly appreciated.

Since your savings-account, checking-account, and credit-account classes are identical or nearly soconsider starting with a base class:. You might want to make Customer. Though adding accounts isn't functionality usually found in an ATM!

As far as your code not working, what does it do? What does it -not- do? Does your program crash and if so what error message do you get? I think I know what you mean, but since I don't know what code you got from your tutor, and what of the code you've added to, I'm not sure where you're stuck in doing what you need. I see a Transact::readRecord method.

You could use something very similar to that to create a Customer::readCustomer method, which would populate your Customer class. From the data file, it looks like account-types are K, S or C, or if you read an X then you're done with that customer and go on to the next one. Write just enough code to do that, and test it. Then think about what you need to do next.

I'll try and attatch it for you. Among other things, your assignment sheet specifically instructs you to do what I suggested: start with a GenericAccount class and derive the other accounts from that.

The assignment is so specific and detailed, you should probably consider following it, step by step, and then post back here when you can't get a step to work the way you want. Members of a class which are safe to be inherited by derived classes should be "protected:" instead of "private:".We will look at two simple example designs for object oriented systems — a Simple Banking System and a Traffic Light Application.

We must define how we would like our system to behave and how it will interact with its users.

Storing passwords

To keep the simulation simple When the program starts, we would like a welcome message displayed telling us what we can do. We would like this message to Ask which account number we wish to work with or if we want to shutdown. Offer a list of transactions available and repeatedly prompt for transactions to.

atm transaction program using class and object

For each transaction requested the program may need to respond. It will then complete the requested transaction. When transacting an account the allowable requests that can be handled by the ATM will be A deposit transaction will require an amount to deposit. This amount will be added to the account balance. A withdraw transaction will require an amount to withdraw. This amount will be subtracted from the account balance. A balance transaction will display the current balance on the account.

An exit transaction will return to the initial ATM start up message. A help transaction will print out some help on the screen for the user. Now that we have defined the requirements of the user interface and fundamental behaviour we can now go on to design and implement the program. We are going to implement our program using the java object-oriented language so we will use an object oriented design approach to this program to make it easier to implement from the design. One Bank which maintains the accounts.

One Automated Teller Machine represented by our terminal window and keyboard.In this Python tutorial, learn the basic, common functions when using an ATM machine. This Python tutorial will give a basic overview on creating a class with methods and objects while implementing loops such as while loops and for loopsand if statements. The Random module allows a program to create random numbers by using the random. If we wanted a random integer, we can use the randint function and it will accept two parameters of numbers lowest and highest.

A class is used for creating objects. Since we are using Python in this tutorial, a class is created by a keyword class. Once the class is created, the object within the class will then be called the instance of the class.

Now we take the requirements that we created from the above and create functions. We can define the functions to provide the given functionality of the program. The function blocks are started with def and followed with the function name and parenthesis, such as def getId self. Also, we could import a Python program as a module, but the main method will not execute.

The entry point of any program is the main function, but the interpreter of python will execute the source file code sequentially. This is why the main method has a technique, so that the main method will be executed when the program is executed directly and not when the module is imported. By creating the main method, we will use a range to have all users to enter a 4-digit pin to access their account. We will use the while True loop because it will loop forever.

UML - ATM Transaction - Class Diagram

As long as the loop stays True, the loop will indefinitely loop. I hope this Python tutorial on creating an ATM program for checking account balance, withdrawing funds, and depositing funds was helpful.

Save my name, email, and website in this browser for the next time I comment. This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

I'm trying to create an e-ATM console app using C using inheritance, but every time I debug I see that the derived class values are nullwhereas the base class fields or properties are filled with values.

Subscribe to RSS

Why is the derived class not showing the list with their data even after it is inherited from the base class? An ATM object does not automatically inherit the values from a previously created CreateAccount object, they are two completely different, unrelated entities. Here is how it's done with proper use of inheritance which is useless in this case actually. Dictionary is the proper datastructure to use in this case because you can avoid duplicates with it.

Also from this code you might want to remove the accountNo from Account class to avoid duplicate numbers being kept and the ask it beffore calling GenerateAccount method. So this is full console app:. CreateAccount is an operation of Atm and this is why I don't think you should be using inheritance. I propose this solution:.

How are we doing? Please help us improve Stack Overflow. Take our short survey. Learn more. How to Create a simple atm program in c using inheritance Ask Question. Asked 4 years, 9 months ago. Active 4 years, 9 months ago. Viewed 9k times. IsNullOrEmpty value value. Parse Console. WriteLine "Menu" ; Console. WriteLine "1. Create Account" ; Console. WriteLine "2. ATM" ; Console. Well it would be helpful if you could show us the Main method. Right off the bat I can see that you are not using any constructors which would help you with creating the objects.

I've added the Main method. Hope now you will find it useful. I think you are misusing inheritance. You should create two classes ATM and Account. Let ATM keep a list of Accounts and have methods CreateAccount that adds a new account to the list and Deposit that adds funds to an account.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

This code is from my "virtual ATM machine" program which deals with customers depositing, checking balance and withdrawing money from their account.

When I deposit the money, it displays that it gets deposited. Which means the values didn't get updated from the previous function.

The problem is with the deposit function, im guessing. But I posted the complete program for your disposal. The codes that I have 'commented' out are ones I used for testing or ones that I'm still working on, not really needed for now Y. You need to pass your bankAccount from one function to another. Your functions modifying a bankAccount currently use a local bank account that gets discarded when the scope of the function is left! Learn more.

Asked 6 years, 10 months ago. Active 6 years, 10 months ago. Viewed 15k times. Here's the complete code for my program and the problem stated below. DinukaPJJayasuriya You have to learn to select the relevant parts. Good thing my full name is only 18 characters, else I wouldn't be able to use your bank! DinukaPJJayasuriya: Then you're doing it wrong. Instead of trying to paste your actual code, build a new, small, self-contained program with a main that we can compile, is less than 50 lines, and illustrates exactly what the problem is.

In doing this excercise, you'll help us to help you and help yourself by learning more about the language, and you might even find the problem on your own.

Active Oldest Votes. An ugly hack could be to use a global instead considering the simplicity of your application. The very simplest method you could do this is take out bankAccount b; and move it before main - by making it global it will be available everywhere.

This would not be recommended for a real application but before you learn a bit more about the language, it should be good enough. See, now he's going to make everything globals until he gets fired by someone like me. I agree with John Dibling globals should not be taught to someone new to the language. They make the code harder to maintain and harder to find where a bug is.

I would have probably passed the bankAccount in by constant reference. The Overflow Blog. The Overflow How many jobs can be done at home? Featured on Meta.

Community and Moderator guidelines for escalating issues via new response….The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable. Forum: Beginning Java. ATM Class. Kristina Hawkins. 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. Thank you!

Junilu Lacar. I like 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.

Any help or tips would be greatly appreciated!!! Swastik Dey. Looks great. 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.

Campbell Ritchie. 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. 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! If they had yelled out instead, "You're about to get hit by a bus! The instruction to "use initialize method to add customers to HashMap" is like just telling you to jump three feet to your left. 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. 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.

atm transaction program using class and object

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 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.

atm transaction program using class and object

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 best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable. Forum: Beginning Java.

ATM Class. Kristina Hawkins. 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. Thank you! Junilu Lacar. I like 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.

Any help or tips would be greatly appreciated!!! Swastik Dey. Looks great. 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. Campbell Ritchie. 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.

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! If they had yelled out instead, "You're about to get hit by a bus! The instruction to "use initialize method to add customers to HashMap" is like just telling you to jump three feet to your left. 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.


thoughts on “Atm transaction program using class and object”

Leave a Reply

Your email address will not be published. Required fields are marked *