Start by designing a class called Account. This class contains the following private or hidden data attributes: acct_num, a unique identifying account number. owner, the name of the owner of the checking account. balance, the available balance in the account. The Account class will have the following methods: • An initialization method ( _ init _) that can be used to create an instance of the Account class. All the data attributes must be specified as arguments. This method prevents initializing the balance to a negative number by assigning zero (0) to the balance attribute and displaying an error message that reports any attempt to initialize the balance data attribute to a negative value. • • • • A deposit method that accepts as an argument the amount of money to be added to the existing balance. If the amount is not a positive number, ignore the transaction and display an error message that reports the attempt. A withdrawal method that attempts to reduce the account balance. This method must not reduce the account balance below zero. If an argument is passed to this method that is not a positive value or would reduce the account balance below zero, ignore the transaction and display an error message instead that reports the attempt. A get_acct_num accessor method that returns the value of the acct_num data attribute. A get_owner accessor method that returns the value of the owner data attribute. A get_balance method that returns the value of the balance. Place the class definition for Account in a separate file named "Account.py" and then include an "import Account" statement in your program to gain access to the class definition. Your Python program will read and process two input files and create a single output file as well as displaying limited console output. Your program will read the contents of a file named "accounts.txt" and use the contents to initially create and define several Account objects. The "accounts.txt" text file contains the definition of several accounts. Each record in this file contains the following information in this order: 1. owner's name 2. account number 3. initial balance The fields in this file are comma-separated. That is, each field is separated from the next field by a comma. Example records for this file look like this: Hal Jordan, 12345,500 Oliver Queen, 23456, 1000 Steve Rogers, 67543,250 Barry Allen, 12507, 450 Bruce Wayne, 78234,2500 Arthur Curry, 87123,560 Diana Prince, 65439,3250 After creating and initializing instances of the Account class, display a line on the console (screen) using a print statement that reports how many accounts were created.
Start by designing a class called Account. This class contains the following private or hidden data attributes: acct_num, a unique identifying account number. owner, the name of the owner of the checking account. balance, the available balance in the account. The Account class will have the following methods: • An initialization method ( _ init _) that can be used to create an instance of the Account class. All the data attributes must be specified as arguments. This method prevents initializing the balance to a negative number by assigning zero (0) to the balance attribute and displaying an error message that reports any attempt to initialize the balance data attribute to a negative value. • • • • A deposit method that accepts as an argument the amount of money to be added to the existing balance. If the amount is not a positive number, ignore the transaction and display an error message that reports the attempt. A withdrawal method that attempts to reduce the account balance. This method must not reduce the account balance below zero. If an argument is passed to this method that is not a positive value or would reduce the account balance below zero, ignore the transaction and display an error message instead that reports the attempt. A get_acct_num accessor method that returns the value of the acct_num data attribute. A get_owner accessor method that returns the value of the owner data attribute. A get_balance method that returns the value of the balance. Place the class definition for Account in a separate file named "Account.py" and then include an "import Account" statement in your program to gain access to the class definition. Your Python program will read and process two input files and create a single output file as well as displaying limited console output. Your program will read the contents of a file named "accounts.txt" and use the contents to initially create and define several Account objects. The "accounts.txt" text file contains the definition of several accounts. Each record in this file contains the following information in this order: 1. owner's name 2. account number 3. initial balance The fields in this file are comma-separated. That is, each field is separated from the next field by a comma. Example records for this file look like this: Hal Jordan, 12345,500 Oliver Queen, 23456, 1000 Steve Rogers, 67543,250 Barry Allen, 12507, 450 Bruce Wayne, 78234,2500 Arthur Curry, 87123,560 Diana Prince, 65439,3250 After creating and initializing instances of the Account class, display a line on the console (screen) using a print statement that reports how many accounts were created.
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 7PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,