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

AI Thread Summary
The discussion revolves around transitioning a text-based banking system interface written in Python from a procedural to an object-oriented programming (OOP) structure. The user seeks guidance on how to effectively implement OOP concepts, expressing confusion over the complexity of the instructor's examples. Key points include the need to define distinct classes for Users, Accounts, Transactions, Banks, and Menus, each with specific attributes and methods. The importance of not merely consolidating code into a single class is emphasized, as true object-oriented design requires a clear separation of responsibilities and functionalities. The discussion also touches on the forum's policy regarding thread deletion, indicating that threads with replies cannot be removed.
sedat96
Messages
1
Reaction score
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
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"?
 
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:
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
 
Our policy is to not delete such threads when there have been replies to the question.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top