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

Click For Summary

Discussion Overview

The discussion revolves around the implementation of a banking system in Python using object-oriented programming principles. Participants explore how to transition from a function-based approach to an object-oriented design, addressing specific structural challenges and design considerations.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant expresses difficulty in rewriting a text-based banking system using object-oriented programming, noting that previous attempts have become complicated.
  • Another participant suggests that simply placing everything into a single class does not constitute proper object-oriented design and emphasizes the need to define distinct objects, such as an account, with specific properties and methods.
  • A later reply outlines implementation notes, recommending the creation of several classes including User, Account, Transaction, Bank, MenuEntry, and Menu, each with defined attributes and methods necessary for the banking system.
  • One participant questions the relevance of the implementation notes provided, indicating a desire to delete the thread after receiving responses.
  • A response clarifies the forum's policy against deleting threads that have received replies, indicating a commitment to maintaining the discussion history.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to implement the object-oriented design, with multiple viewpoints on how to structure the code and what classes are necessary. The discussion remains unresolved regarding the specific implementation details.

Contextual Notes

Participants express uncertainty about the correct structure and implementation of the object-oriented design, highlighting potential missing assumptions and the complexity of transitioning from a procedural to an object-oriented approach.

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.
 

Similar threads

Replies
15
Views
11K
Replies
2
Views
3K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 1 ·
Replies
1
Views
8K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 1 ·
Replies
1
Views
11K
  • · Replies 1 ·
Replies
1
Views
4K