Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Knowledge of Object-Oriented Programming with the implementation of a banking application in python. Task 1: Create User class Create and initialize the User class. -

Knowledge of Object-Oriented Programming with the implementation of a banking application in python.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Task 1: Create User class Create and initialize the User class. - In your week4 folder, create a new file and name it workshop4.py. - In this file, declare a class and give it the name User. - Give the User class three instance attributes: name, pin, and password. Test Task 1 - For this assignment, you will write "driver code" for each task. Driver code is not a part of your application but is used to test parts of your application. - Write this driver code in the same file (workshop4.py), but keep it at the bottom of the file, separated from the rest of your code. - Add a comment above your driver code to separate it from the rest of your code, similar to this: - Then write your driver code for Task 1 underneath this comment. - For your driver code: - Write code to instantiate an object from the User class, providing the name, pin, and password as arguments. - For example, you could use "Bob" as the name, 1234 as the pin, and "password" as the password. - Write a print statement to print the name, pin, and password attributes of this object. - Save and run your code. The output should look similar to this: python workshop4.py Bob 1234 password - After testing, comment out the driver code for this task. Task 2: Add User class instance methods - Write three methods for the User class: 1. change_name() - Changes the name of the User. 2. change_pin() - Changes the PIN of the User. 3. change_password() - Changes the password of the User. Test Task 2 - Below the commented-out driver code for Task 1, add the driver code for Task 2. - You can add a comment such as: """ Driver Code for Task 2 """ - ...then write your driver code under this comment. - For your driver code: - Once again, instantiate an object from the User class, providing the name, pin, and password as arguments. - These can be the same code and arguments as in Task 1. For example, the arguments: "Bob", 1234, "password". - Again, print the object's attributes. - Call each of the three methods you created to change the name, pin, and password. - Print the updated attributes. - Save your changes and run the updated code. - The output should look similar to this: - Declare a class and give it the name BankUser. - Have the BankUser class inherit the User class. This means it should be child class/subclass of the User parent class/superclass. - It should inherit the instance attributes of name, pin, and password. - Use the super() function to initialize these inherited attributes using the superclass. - Give the BankUser class its own instance attribute as well, which the User class does not have: balance, initialized to a value of 0. - This attribute is not passed in via the parameter list. Test Task 3 - Add a comment similar to this under your commented-out driver code for Task 2: """ Driver Code for Task 3""" - For your driver code: - Instantiate an object of the BankUser class, providing arguments for the name, pin, and password. - Print the attributes of the BankUser object you created: name, PIN, password, and balance. - Save and run your code. The output should look similar to this: \$ python workshop4.py Bob 1234 password 0 - The first three attributes printed (name, PIN, password) should match whatever arguments you supplied when instantiating the object. - The fourth attribute printed (balance) should be 0. - After testing, comment out the driver code for Task 3. Task 4: Add BankUser class instance methods - Write three methods for the BankUser class: 1. show_balance() - Prints the BankUser object's balance 2. withdraw() - Withdraws money, decreases the account balance 3. deposit() - Deposits money, increases the account balance Test Task 4 - Add a comment similar to this under your commented-out driver code for Task 3 : """ Driver Code for Task 4""" - For your driver code: - Instantiate an object of the BankUser class, providing arguments for the name, pin, and password. - This can be a copy of the same code you used in Task 3. - Call the show_balance() method of the object. - Call the deposit() method, depositing some positive number. - Call the show_balance() method once again. - Call the withdraw() method, withdrawing some number lower than what was deposited. - Call the show_balance() method again. - Save and run the updated code. The output should look similar to this: \$ python workshop4.py Bob has an account balance of: 0 Bob has an account balance of: 1000.0 Bob has an account balance of: 500.0 - After testing, comment out the driver code for Task 4. Test Task 5: - Add a comment similar to this under your commented-out driver code for Task 4 : """ Driver Code for Task 5""" - For your driver code: - Instantiate an object of the BankUser class, providing arguments for the name, pin, and password. - This can be a copy of the same code you used in Task 4. - Instantiate a second object of the BankUser class, providing different arguments. - Deposit $5000 into the account of this second user using the deposit() method. - Show the balance of the second user. - Show the balance of the first user. - Have the second user transfer $500 to the first user, using its transfer_money() method. - Again, show the balance of each user. - If the money transfer was successful, now have the second user request some money from the first user, using its request_money() method. - Again, show the balance of both users. - Save and run your code. The output should look similar to this: \$ python workshop4. py Alice has an account balance of: 5000 Bob has an account balance of: 0 You are transferring $500 to Bob Authentication required Enter your PIN: 5678 Transfer authorized Transferring $500 to Bob Alice has an account balance of: 4500 Bob has an account balance of: 500 You are requesting $250 from Bob User authentication is required... Enter Bob's PIN: 1234 Enter your password: alicepassword Request authorized Bob sent $250 Alice has an account balance of: 4750 Bob has an account balance of: 250 - If the wrong PIN is given when a money transfer is requested, the result should look similar to this: \$ python workshop4.py Alice has an account balance of: 5000 Bob has an account balance of: 0 You are transferring $500 to Bob Authentication required Enter your PIN: 9999 Invalid PIN. Transaction canceled. Alice has an account balance of: 5000 Bob has an account balance of: 0 - If when requesting money, the PIN is incorrect, the result should look similar to this: \$ python workshop4.py Alice has an account balance of: 5000 Bob has an account balance of: 0 You are transferring $500 to Bob Authentication required Enter your PIN: 5678 Transfer authorized Transferring $500 to Bob Alice has an account balance of: 4500 Bob has an account balance of: 500 You are requesting $250 from Bob User authentication is required... Enter Bob's PIN: 9999 Invalid PIN. Transaction canceled. Alice has an account balance of: 4500 Bob has an account balance of: 500 - If when requesting money, the PIN is correct but the password is incorrect, the result should look similar to this: $ python workshop4.py Alice has an account balance of: 5000 Bob has an account balance of: 0 You are transferring $500 to Bob Authentication required Enter your PIN: 5678 Transfer authorized Transferring $500 to Bob Alice has an account balance of: 4500 Bob has an account balance of: 500 You are requesting $250 from Bob User authentication is required... Enter Bob's PIN: 1234 Enter your password: wrongpassword Invalid password. Transaction canceled. Alice has an account balance of: 4500 Bob has an account balance of: 500

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago

Question

The nature and importance of the global marketplace.

Answered: 1 week ago