IMAT4038 By Scottie MAN
IMAT4038 Assignment Two
Objective
In this assignment, we are going to develop a java program using Object-Oriented (OO) approach. We will create a java class to represent a bank account. This class will have few private attributes (variables) to store name of account holder and corresponding balance, and few public methods (functions) to allow print out of balance, balance adjustment, and transfer between different bank accounts. Also, we will create a static attributes (variable) to show how many bank accounts were created.
Deliverable
You are required to upload your source code of this laboratory to SOUL. The submitted source code must implement all the functions described in the “Tasks” section.
File Name Convention
In order to easily distinguish the java code(s) you submitted to SOUL, you must prefix your file names and class names with a capital letter “S” followed by your student ID as shown in following examples. In this assignment, you are required to submit two java code files shown in following. Please “zip” them up and use your student ID as the zip-file name.
e.g. Student ID: 2014646
Zip file name: S2014646.zip
Java file with main function: S2014646.java [This file is provided but you need to modify it] Java file with class of bank account: S2014646Bank.java [This file is totally created by yourself!!]
P1
IMAT4038
By Scottie MAN
Task
Task 1 – Create a Class to represent a bank account (Marks: 80) If your student ID is S2014646:
The class name will be S2014646Bank
File name will be S2014646Bank.java
This Class should have the following static variable and static function. (20 marks) Static Variable:
A private integer to store the number of bank accounts were created Static Functions:
A public function to print the number of bank accounts were created o Method signature description
public static void printTotalNumAcc()
Also, this Class should have the following non-static variables and non-static functions. (60 marks) Non-Static Variables:
A private String to store the name of bank account holder
A private integer to store the balance of bank account
Non-Static Functions:
Constructor to correctly initiate values of all private variables (no matter they are static or not)
o Initialize the name of bank account holder
o Initialize the balance of bank account
o Increase the private static variable, which represents the number of created bank
accounts, by one
o Method signature description (Assume student ID: S2014646)
public S2014646Bank(String acc_name, int acc_balance) Function to print the account balance to command prompt
o Method signature description
public void printBalance()
Function to adjust the balance by user input, and print adjustment to command prompt o Method signature description
public void adjustBalance(int adjust_balance)
Function to transfer certain amount of money to another account, and print details of transfer
o Method signature description (Assume student ID: S2014646)
public void transferTo(int trans_amount, S2014646Bank account)
P2
IMAT4038 By Scottie MAN
Task 2 – Modify the java file with main function (Marks: 20)
This file is provided in course webpage with file name S2014646.java and class name S2104646
You need to modify the class name, file name, and anything using assumed ID to your own student ID
Hint 1: How to compile with two java files To compile two java files:
Hint 2: How to execute the entire program and the expected output To execute the program:
P3
IMAT4038 By Scottie MAN
Appendix: Content of file S2014646.java
P4