KEMBAR78
PROG10004 Assignment 3 | PDF | Method (Computer Programming) | Parameter (Computer Programming)
0% found this document useful (0 votes)
7 views8 pages

PROG10004 Assignment 3

The assignment requires students to create a Python application for banking operations, including deposit and withdrawal functionalities for savings and chequing accounts. Students must implement classes for consumers, accounts, and exceptions, and provide a method to display account details. Submissions must include a zip file of the code and a screen recording of the app execution, adhering to specified naming conventions.

Uploaded by

mdho4164
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views8 pages

PROG10004 Assignment 3

The assignment requires students to create a Python application for banking operations, including deposit and withdrawal functionalities for savings and chequing accounts. Students must implement classes for consumers, accounts, and exceptions, and provide a method to display account details. Submissions must include a zip file of the code and a screen recording of the app execution, adhering to specified naming conventions.

Uploaded by

mdho4164
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

PROG10004 – Programming Principles

Assignment #3

Evaluation: 100 Points. (10%)

Instructions:
• This assignment is to be done individually.

Submissions:
• Create a folder named as Firstname_Lastname_A3 in which you should be creating all the python
files required to perform the task specified below.
• Once you are done, create a zip folder (No .7zip or .rar files please) upload the completed program
in Assignment-3 SLATE drop box.
• Create and upload a screen recording showing your app execution and/or errors.
• You submission should have two separate files; 1) .zip containing code 2) .mov or .mp4 for screen
recording.

Task:

The application will allow the user to perform various banking operations such as deposit and
withdrawal of money from the bank account. The bank offers two types of accounts: savings account
and chequing account. To test your app, you will consider that the bank consists of predefined list of
accounts which are provided to you in the start-up code. Please find the details for the task below.

Consumer class:
This class will represent following consumer information. Both the field variables must be private
members.
• id – consumer ID e.g., S102
• name – name of the consumer

Initializer : Create parameterized initializer to accept two parameters for both the field variables.

Methods :
• Accessor & Mutators : Create necessary accessor and mutator methods for field variables.
• __str__() : Create __str__() function to return a string containing values of field variables.

Account class:
This class inherits from Consumer class. It will represent following account information. The field
variables must be having protected access.
• accountNum – account number e.g., 222210212

Initializer : Create parameterized initializer to accept necessary parameters for field variables of
account class and the parameters of the super class.

Jigisha Patel Page 1 of 8


Methods :
• withdraw(amount : float) – this is an abstract method which will accept amount to withdraw as
parameter
• deposit(amount : float) – this is an abstract method which will accept amount to deposit as parameter
• __str__() : Create __str__() function to return a string containing values of field variables of account class
as well as super class.

Account Exceptions:
You are to create the following four user-defined exceptions to represent various errors that will be
thrown when specific condition is not fulfilled while performing banking operations on different types
of account. All the classes stated below will inherit from the Exception class to create user-defined
exceptions.
• Insufficent_Balance_Error class
o This class will have only one method; __str__() method that will return string stating that
“Insufficient balance in the account. Cannot withdraw.”

• Minimum_Balance_Error class
o This class will have only one method; __str__() method that will return string stating that “You
must maintain minimum $3000 balance in Saving account.”

• Incorrect_Amount_Error class
o This class will have only one method; __str__() method that will return string stating that “You
must provide positive number for amount to be deposited.”

• Overdraft_Limit_Error class
o This class will have only one method; __str__() method that will return string stating that
“Overdraft Limit exceeded. You can only use $2000 from overdraft.”

SavingsAccount class:
This class inherits from Account class. It will represent following account information. The field variables
must be having private access.
• balance

Initializer : Create parameterized initializer to accept necessary parameters for field variables of
SavingsAccount class and the parameters of the super class. If the balance parameter value is not
provided, use the default value of 0.0. This class will also implement the abstract methods inherited
from the super class.

Methods :
• withdraw(amount : float)
o This is an implementation of abstract method inherited from super class. The method will accept
amount to withdraw as parameter and try to deduct it from the balance.
o The method must check if there is sufficient balance in the account; if not, raise the
Insufficient_Balance_Error and display appropriate message in the except block.

Jigisha Patel Page 2 of 8


o Also, check if after the amount will be deducted from the balance, $3000 will remain in the
balance. If not, raise the Minimum_Balance_Error and display appropriate message in the except
block.
o If there is no exception raised, deduct the amount from the balance and display the updated
balance.

• deposit(amount : float)
o This is an implementation of abstract method inherited from super class. The method will accept
amount to deposit as parameter and try to add it to the balance.
o The method must check if the given amount is not less than zero (0); if not, raise the
Incorrect_Amount_Error and display appropriate message in the except block.
o If there is no exception raised, add the amount to the balance and display the updated balance.

• __str__() : Create __str__() function to return a string containing values of field variables of
SavingsAccount class as well as super class.

ChequingAccount class:
This class inherits from Account class. It will represent following account information. The field variables
must be having private access.
• balance

Initializer : Create parameterized initializer to accept necessary parameters for field variables of
ChequingAccount class and the parameters of the super class. If the balance parameter value is not
provided, use the default value of 0.0. This class will also implement the abstract methods inherited
from the super class.

Methods :
• withdraw(amount : float)
o This is an implementation of abstract method inherited from super class. The method will accept
amount to withdraw as parameter and try to deduct it from the balance.
o The ChequingAccount holders can deduct up to $2000 more than the balance. For instance, if
the balance is 5000, the consumer can withdraw up to $7000 from the account.
o The method must check if the amount to be deducted is less than (2000 + balance), if not, raise
the Overdraft_Limit_Error and display appropriate message in the except block.
o If there is no exception raised, deduct the amount from the balance and display the updated
balance.

• deposit(amount : float)
o This is an implementation of abstract method inherited from super class. The method will accept
amount to deposit as parameter and try to add it to the balance.
o The method must check if the given amount is not less than zero (0); if not, raise the
Incorrect_Amount_Error and display appropriate message in the except block.
o If there is no exception raised, add the amount to the balance and display the updated balance.

• __str__() : Create __str__() function to return a string containing values of field variables of
ChequingAccount class as well as super class.

Jigisha Patel Page 3 of 8


Bank class:
This class represents the bank that consist of several accounts. Create the following members of the
class:
accountList[] – this is a class variable of list type that will consist of objects of accounts.

Initializer : The initializer for this class will be marked as staticmethod. The initializer will create several
object of SavingAccount class and ChequingAccount class and add it to the accountList class variable.
Use the following is the code snippet for the initializer code.

Bank._accountList.append(SavingsAccount("S101", "James Finch", 222210212, 3400.90))


Bank._accountList.append(SavingsAccount("S102", "Kell Forest", 222214500, 42520.32))
Bank._accountList.append(SavingsAccount("S103", "Amy Stone", 222212000, 8273.45))
Bank._accountList.append(ChequingAccount("C104", "Kaitlin Ross", 333315002, 91230.45))
Bank._accountList.append(ChequingAccount("C105", "Adem First", 333303019, 43987.67))
Bank._accountList.append(ChequingAccount("C106", "John Doe", 333358927, 34829.76))

Methods:
• showAll()
o This method will be denoted as a static method which will be accessible through the class name.
o The method will iterate through the accountList and display all the account details.

Application class:
The application class will define a run() method to test various classes. Create the object of the
application class and call the run() method to test the program. Use the following code snippet for the
run() method.

def run(self):
Bank()
Bank.showAll()
Bank._accountList.append(SavingsAccount("S647", "Alex Du", 222290192, 4783.98))
Bank._accountList.append(ChequingAccount("C576", "Dale Stayne", 333312312, 12894.56))

print(f'{ "-" * 90}')


print(f'Trying to withdraw $500.00 from the following account')
print(Bank._accountList[0].__str__())
Bank._accountList[0].withdraw(500.00)
print(f'{ "-" * 90}')

print(f'{ "-" * 90}')


print(f'Trying to deposit $-250.00 to the following account')

Jigisha Patel Page 4 of 8


print(Bank._accountList[1].__str__())
Bank._accountList[1].deposit(-250.00)
print(f'{ "-" * 90}')

print(f'{ "-" * 90}')


print(f'Trying to withdraw $10000.00 to the following account')
print(Bank._accountList[2].__str__())
Bank._accountList[2].withdraw(10000.00)
print(f'{ "-" * 90}')

print(f'{ "-" * 90}')


print(f'Trying to deposit $5000.00 to the following account')
print(Bank._accountList[2].__str__())
Bank._accountList[2].deposit(5000.00)
print(f'{ "-" * 90}')

print(f'{ "-" * 90}')


print(f'Trying to deposit $7300.00 to the following account')
print(Bank._accountList[3].__str__())
Bank._accountList[3].deposit(7300.00)
print(f'{ "-" * 90}')

print(f'{ "-" * 90}')


print(f'Trying to withdraw $45000.40 from the following account')
print(Bank._accountList[4].__str__())
Bank._accountList[4].withdraw(45000.40)
print(f'{ "-" * 90}')

print(f'{ "-" * 90}')


print(f'Trying to withdraw $37000.00 from the following account')
print(Bank._accountList[5].__str__())
Bank._accountList[5].withdraw(37000.00)
print(f'{ "-" * 90}')

Bank.showAll()

Jigisha Patel Page 5 of 8


Sample Output:

Jigisha Patel Page 6 of 8


Jigisha Patel Page 7 of 8
Notes:
1. All assignment shall be submitted by the deadline. Late submissions will be penalized with 10%
per day for up to 3 calendar days after which the assignment cannot be submitted anymore.

2. This assignment shall be completed individually. Remember that completing the assignment by
yourself will ensure your success on the midterm and final exam. See the Academic Honesty at
Sheridan.

3. If you want to use any entitled accommodation for the assignment, you MUST inform the
professor at least 2 working days in advance of the due date.

4. It is mandatory to meet the naming conventions specified for all the files to be submitted.

Jigisha Patel Page 8 of 8

You might also like