create a class in python with a constructor To create instances of the user defined class and practice applying them. Practice implementing loops. Part 1 Instructions: Create a class called BankAccount with the following variables: balance name account_id Create 1 constructor for the class BankAccount (with or without parameters, your choice, but only 1): def __init_(self, name, account_id, balance) def __init_(self) Create the following methods in the BankAccount class: def viewAccountInfo() //prints all account information def withdraw(self, amount) //withdraws from the balance def deposit(self, amount) //deposits to the balance Your task after your class has been created: Create two objects, "personal" and "joint_account" with initial balances of: personal = $1000 joint_account = $3000 Use the constructor to create the objects. Create a program that prompts the user which account they would like to access personal or joint Which account would you like to access? 1. Personal 2. Joint Account 3. Exitonce they select an account, display all account information using the method ViewAccountInfo(). This menu should repeat, the user should be able to select either personal or joint and then be able to select again once they are done with that account. Next show the following menu: What would you like to do next: 1. Deposit 2. Withdraw 3. View Balance 4. Update account holder 5. Exit Do not let them withdraw more than what is in the account, if they attempt, output "Error, Insufficient funds". Once the user has finished depositing or withdrawing to their account, output their old balance, and the new balance.
create a class in python with a constructor To create instances of the user defined class and practice applying them. Practice implementing loops.
Part 1 Instructions:
Create a class called BankAccount with the following variables:
balance
name
account_id
Create 1 constructor for the class BankAccount (with or without parameters, your choice, but only 1):
def __init_(self, name, account_id, balance)
def __init_(self)
Create the following methods in the BankAccount class:
def viewAccountInfo() //prints all account information def withdraw(self, amount) //withdraws from the balance def deposit(self, amount) //deposits to the balance
Your task after your class has been created:
- Create two objects, "personal" and "joint_account"
with initial balances of:
personal = $1000
joint_account = $3000
Use the constructor to create the objects. - Create a program that prompts the user which account they would like to access personal or joint
Which account would you like to access?
1. Personal
2. Joint Account
3. Exitonce they select an account, display all account information using the method ViewAccountInfo().
This menu should repeat, the user should be able to select either personal or joint and then be able to select again once they are done with that account. - Next show the following menu:
What would you like to do next:
1. Deposit
2. Withdraw
3. View Balance
4. Update account holder
5. Exit
Do not let them withdraw more than what is in the account, if they attempt, output "Error, Insufficient funds". Once the user has finished depositing or withdrawing to their account, output their old balance, and the new balance.
Part 2 Instructions accessors and mutators
Make all your class variables private.
Do not allow any of the class variables to be modified without a setter (mutator).
For the balance setter, do not allow any values of 0 or lower.
Do not allow account_id to be modified, you can do this by omitting the setter for account_id, or adding some type of error code if they do try.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images