Object-Oriented Implementation of Python ATM Script: Where Did I Go Wrong?

In summary, to make object-oriented code you need to create a class for each object you want to represent, define attributes for each object, and provide methods for each object.
  • #1
sedat96
1
0
hello everyone,
I am a new member of this forum I found really good topics and good community that helps with many scientific fields. So I have this long text-based user interface for banking system written in python functions , but needs to be written using object oriented programming. I had build many possible structures without reading the implementations of the instructor, but as I read them and try to apply them everything become very complicated.

How can write/re-write the following code(ready) using the objected oriented Python? : http://www.pastebin.ca/3751103

Where did i make a mistake?Here i tried the whole last weak something like this:
http://pastebin.ca/3751105


finally, here are the implementations :http://pastebin.ca/3751108THANKS all and happy new year.
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
Just putting everything into a single class doesn't make the code object-oriented.

Start with a list of objects you want to have. An account, for example. What are the properties of an account? What are things an account can do? Certainly not printing a navigation menu, as your current code suggests! And why do you define an Admin as "some type of account"?
 
  • #3
sedat96 said:
hello everyone,
I am a new member of this forum I found really good topics and good community that helps with many scientific fields. So I have this long text-based user interface for banking system written in python functions , but needs to be written using object oriented programming. I had build many possible structures without reading the implementations of the instructor, but as I read them and try to apply them everything become very complicated.

How can write/re-write the following code(ready) using the objected oriented Python? : http://www.pastebin.ca/3751103

Where did i make a mistake?Here i tried the whole last weak something like this:
http://pastebin.ca/3751105


finally, here are the implementations :http://pastebin.ca/3751108THANKS all and happy new year.
Your second link contains the following:
Implementation Notes:
 You need to create a class to represent a User. It should have type of user (may be one of
“regular”, “admin”), user name, and password as its attributes.
 You need to create a class to represent an Account. It should have user, balance, and
transactions as its attributes. User attribute should be an instance of the User class.
Transactions attribute should be a list which keeps the past user transactions where each
transaction should be an instance of the Transaction class. Whenever an operation is
performed by the user in the below-listed class methods, a new transaction should be
added properly. It should provide the following methods:
o deposit
o withdraw
o transfer
o get_latestN_transactions
 You need to create a class to represent a Transaction. It should have type, amount,
additional_info as attributes. additional_info attribute should be dictionary where the key
should be type/name of some additional info (e.g., ‘recipient’ in transfer transactions) and
the value would be the value of that information field (e.g., the recipient’s name in
transfer transactions). It is up to you to add methods into this class.
 You need to create a class which will represent a Bank. It will have a dictionary of
accounts as an attribute where dictionary will store all accounts as objects (i.e., key would
be account holder’s user name and value would be an Account instance). It should
provide the following methods:
o create_account
o close_account
o compute_and_print_statistics
o load_accounts_from_file
o search_for_an_account2 | P a g e
 You need to create a class which will represent a MenuEntry. Each option on any menu
that you provide to the user will be an instance of MenuEntry class. It will have
option_number and text as its attributes.
 You need to create another class which will represent a Menu. It will have a list of
MenuEntry objects. In your interface, you have four different menus (regular main menu,
admin menu, the small menu that you show after each operation for regular users, and the
small menu that you show after each operation for admin user). Each of these menus
should be represented as separate Menu objects. Menu class should provide the following
methods:
o add_menu_entry – this method should take a text for the new menu entry as
input, and create a new instance of MenuEntry object with the provided text.
Option_number of the new menu item object should be assigned automatically
based on the current size of the Menu. For instance, if the menu currently
contains 1 entry, the new MenuEntry will have option_number 2.
o print_menu_and_get_user_selection – this method should print the menu as
in previous project, ask the user to make a selection, handle any invalid selections
that the user may do, and return the selection option number to the caller.
These notes lay out pretty clearly what you need to do: create a number of classes with the specified properties.
 
Last edited by a moderator:
  • #4
Mark44 said:
Your second link contains the following:

These notes lay out pretty clearly what you need to do: create a number of classes with the specified properties.
man , how can i delete this thread ? thanks in advance
 
  • #5
Our policy is to not delete such threads when there have been replies to the question.
 

1. What is Python ATM script using OOP?

Python ATM script using OOP is a program written in the Python programming language that simulates an ATM machine using the principles of Object-Oriented Programming (OOP). It allows users to perform basic ATM transactions such as checking balance, withdrawing money, and depositing money.

2. How does the Python ATM script using OOP work?

The Python ATM script using OOP works by creating different objects that represent the various components of an ATM machine, such as the user account, the ATM screen, and the cash dispenser. These objects have attributes and methods that allow them to interact with each other and perform the necessary transactions.

3. What are the advantages of using OOP in the Python ATM script?

Using OOP in the Python ATM script allows for better organization and structure of the code, making it easier to understand, maintain, and modify. It also promotes code reusability and reduces the chances of errors or bugs.

4. Can I customize the Python ATM script using OOP to fit my specific needs?

Yes, you can customize the Python ATM script using OOP to fit your specific needs by modifying the code or adding new features. OOP allows for flexibility and scalability, making it easier to adapt the program to different requirements.

5. Is the Python ATM script using OOP secure?

The security of the Python ATM script using OOP depends on the measures implemented by the programmer. OOP itself does not provide security, but it allows for the implementation of security features such as user authentication and encryption of sensitive data.

Similar threads

Replies
15
Views
5K
Replies
2
Views
888
  • MATLAB, Maple, Mathematica, LaTeX
Replies
17
Views
2K
  • Computing and Technology
Replies
1
Views
7K
  • Special and General Relativity
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top