University | University of Wollongong |
Subject | CSIT121 Object Oriented Design and Programming |
Assignment 1
Objectives
- To apply Object Oriented Design (OOD).
- To apply Object Oriented Programming (OOP) using Python.
Submission
- Submit the python code in a txt file containing the code (with comments) and append the execution results in text form after the code as comments to UOW Moodle.
- For full time student:
- File name must be in the form of: TXXF_NAME_UOWID.txt where XX is your tutorial group, NAME is your full name and UOWID is your 7-digit UOW ID number. For example, T02F_JeffreyTan_8080426.txt
- For part time student:
- File name must be in the form of: TXXP_NAME_UOWID.txt where XX is your tutorial group, NAME is your full name and UOWID is your 7-digit UOW ID number. For example, T02P_JeffreyTan_8080426.txt
- Note as there are many tutorial groups, failure to name your file name correctly in the above format might result in zero marks.
- Late submission will be penalized 5% per day late. Please refer to UOW Moodle for the assignment due date (in Singapore time).
Tasks
Write the Python classes to implement the prototype of a Banking Application depicted in the following, draft class diagram.
Class: Customer
The Customer class represents a bank customer who can hold multiple bank accounts. It allows the customer to add, remove, deposit, withdraw, and calculate total balance across all accounts.
Attribute | Description |
---|---|
customer_id | A unique identifier for the customer. |
name | The full name of the customer |
address | The residential address of the customer. |
The email address of the customer. | |
accounts | A list of BankAccount objects associated with the customer. |
Method
__init__
The constructor to initialise the attributes and also create the the first account.
add_bank_account
This method creates a BankAccount object and adds it to __accounts list.
Parameters:
- account_num : Unique number for the account.
- account_type : Type of account (e.g., “Savings”, “Checking”).
- balance : Initial balance in the account.
- created_date (str): The date the account was created. Format : (YYYY-MM-DD)
To keep this assignment simple, we will use string for date.
It should check if the account_num already existed in the account list.
Hire a Professional Essay & Assignment Writer for completing your Academic Assessments
Native Singapore Writers Team
- 100% Plagiarism-Free Essay
- Highest Satisfaction Rate
- Free Revision
- On-Time Delivery
Returns:
- True if the account is created successfully.
- False if the account has not been created.
remove_bank_account
Removes a bank account from the customer.
Parameters:
- account_num_to_remove: The account number to remove.
Returns:
- True if the account was found and removed.
- False if the account was not found.
deposit
Deposits money into a specific account.
Parameters:
- account_num: The account number to deposit into.
- amount: The amount to deposit.
Returns:
- True if the deposit is successful.
- False if the account is not found or deposit amount is invalid.
Page 3 of 4
withdraw
Withdraws money from a specific account.
Parameters:
- account_num (int): The account number to withdraw from.
- amount (float): The amount to withdraw.
Returns:
- True if the withdrawal is successful.
- False if the account is not found or has insufficient funds.
get_bank_account
Retrieves a BankAccount object by its account number.
Return None if the account number is not found.
get_total_balance
Calculates and returns the total balance across all accounts.
add_interest_to_accounts
Adds interest to all bank accounts belonging to the customer.
get_customer_info
Returns the customer’s basic details in a readable format.
Returns: A string containing:
ID: <customer_id>, Name: <name>, Address: <address>, Email: <email>
__str__
Returns a string representation of the customer.
A string displaying the customer’s ID and total balance:
Customer <customer_id>: Total Balance = <total_balance>
Class: BankAccount
The BankAccount class represents a bank account belonging to a customer. It includes functionality for deposits, withdrawals, interest calculation, and balance retrieval.
Attribute | Description |
---|---|
interest_rate | Class variable. Shared by all instances of BankAccount. Defines the interest rate (in percentage) applicable to all accounts. This is set using the set_interest_rate() class method. |
account_num | Stores the unique account number for the bank account |
account_type | Defines the type of account (e.g., “Savings”, “Checking”). |
customer_id | Stores the customer ID to which this account belongs |
balance | Stores the current account balance. |
Attribute | Description |
---|---|
created_date | Stores the date the account was created String (YYYY-MM-DD format) |
Buy Custom Answer of This Assessment & Raise Your Grades
Method
__init__
The constructor to initialise the attributes.
deposit
Deposits a specified amount into the account.
Returns:
- True if the deposit was successful.
- False if the deposit amount is invalid (e.g., negative or zero).
withdraw
Withdraws a specified amount from the account if funds are sufficient.
Returns:
- True if the withdrawal was successful.
- False if the withdrawal amount is invalid (negative or zero) or if there are insufficient funds.
get_account_number
Retrieves the account number.
get_balance
Retrieves the current balance of the account.
add_interest
Applies the interest rate to the account balance.
current balance * (1+interest rate/100)
set_interest_rate
Class method
Sets the class variable interest rate for all bank accounts.
__str__
Returns a string representation of the account.
Account <account_num> (<account_type>): $<balance>, Created: <created_date>
You will carry out OOD and OOP as follow:
- You must choose an appropriate data type (class) for each attribute.
- You must define a main function which includes sufficient test cases to demonstrate the functionalities of the program. For instance, in the main function, you may
- Create a Customer object with a BankAccount
- Using the Customer object,
- Create a few BankAccount for that customer.
- Make a few deposits to a few different accounts.
- Make a few withdrawals from a few different accounts.
- Set the BankAccount interest rate.
- Using the Customer object,
- Add interests to all the account
- Check if the balance in all the accounts is correct
- Make necessary error checks (e.g. invalid bank account number)
Stuck with a lot of homework assignments and feeling stressed ? Take professional academic assistance & Get 100% Plagiarism free papers
Looking for Plagiarism free Answers for your college/ university Assignments.
- DSM500 Machine Learning Project Proposal: Retail Sales Forecasting with Time Series Models
- Project Management Assignment 2: The Shard UK Case Study on Risk & Stakeholder Strategies in Construction Projects
- PSB333MAE Assignment 1 Report: Structural Analysis & Optimisation Using SolidWorks and Direct Stiffness Method
- Economics Assignment Questions: Factors of Production, Demand Behavior & Global Coffee Market
- GSGM 7223 Strategic Transformation Assignment: Global Foods Ltd Case Study on Change Management and Digital Innovation
- PAC Research Proposal Report Assignment 1: Accounting and Finance Topics
- 7025CL Management Report Assignment: Investment Appraisal and Cash Budgeting – A Financial Feasibility Study for Gamiquest Corporation
- AWS Cloud Migration Assignment : FashionOnline Case Study for PDPA-Compliant Infrastructure
- Comparative Essay on Blake’s Moral Vision and Keats’s Aesthetic Ideal
- Essay on Marginalisation of Vulnerable Groups in Singapore Through a Sociological Lens