Overview
For this assignment, you will generate a UML class diagram for a class and implement it. You will then write a driver that asks for the user's information to create a new account and then present the user with a series of options to interact with the account. In addition, you will learn how to use GitHub classroom to start a new project and submit your solution using git version control.
Pre-Lab (DUE BEFORE LAB - see due date in Canvas)
As part of the pre-lab activity you will see how to use GitHub Classroom to start your lab assignment and submit it when you are finished. You will also be adding the CheckStyle tool to help you with the MSOE Coding Standard
- How to start a new project from your GitHub repository
- How to commit changes to your local repo
- How to push changes from your local repo to GitHub
- Watch [5:24] [link]
The project is cloned from the GitHub repo to your local machine at the three minute mark in the video. You will likely need to authorize IntelliJ to access your GitHub account. Hopefully the process is simple enough, but you can see screenshots of what to do in Figures 13-16 of this page.
- What is the MSOE Coding Standard?
- What is CheckStyle?
- How to install CheckStyle in IntelliJ
The full MSOE Coding Standard can be found on our Coding Standards Page. Please be aware the videos are a few years old, and the link to the CheckStyle configuration file has changed. The correct configuration can be found at the bottom of the Coding Standards page, along with instructions on how to install CheckStyle.
What Must Be Done by the Pre-lab Due Date?
- Download and install CheckStyle as a plug-in for IntelliJ
- Configure CheckStyle for all new Projects
- Accept your instructor's invitation to the lab 6 assignment in Canvas
- Associate your GitHub account (create one if you don't have one) with your name in GitHub Classroom
- Clone the project, openning it in IntelliJ
- Rename the
username
package to your username - Commit the changes
Assignment
BankAccount
Class
Using the provided JavaDoc for the BankAccount
class,
create a UML class diagram for the class. Show this to your professor during lab.
Once you receive feedback, implement the BankAccount
class with functionality
that conforms to the documentation.
ATM
Class
Create a driver class called ATM
. The program must:
- Ask the user for a name, age, and pin and then use the information to create an new instance of the
BankAccount
class. - The program will print the details of the account, such as the name, age, and account balance, in a nice format. See the sample output below.
- The program will then ask the user if they want to:
- Withdraw funds
- Deposit funds
- Exit
- Unless the user selects Exit, the program should print the account details and the options again after each selection.
- When withdrawing funds, you must ask the user for their pin in addition to the amount they wish to withdraw. If the withdrawal fails (i.e., the
withdraw()
method returns-1
), print an appropriate error message. - When depositing funds, if the deposit method fails (i.e., the
deposit()
method returns-1
), print an appropriate error message. - When exiting, print an appropriate exit message.
Sample Program Interaction
Welcome to University Bank.
Follow the prompts below to setup your new account.
Enter your name: Philip J. Fry
Enter your age: 25
Enter a pin (e.g., 1234): 1077
Account details:
Name: Philip J. Fry
Age: 25
Balance: $0.00
Options:
1. Deposit.
2. Withdraw.
3. Quit.
What would you like to do: 1
How much would you like to deposit: -10
Error depositing funds.
Account details:
Name: Philip J. Fry
Age: 25
Balance: $0.00
Options:
1. Deposit.
2. Withdraw.
3. Quit.
What would you like to do: 1
How much would you like to deposit: 0.93
Account details:
Name: Philip J. Fry
Age: 25
Balance: $0.93
Options:
1. Deposit.
2. Withdraw.
3. Quit.
What would you like to do: 2
How much would you like to withdraw: 100
Enter your pin: 1077
Error withdrawing funds.
Account details:
Name: Philip J. Fry
Age: 25
Balance: $0.93
Options:
1. Deposit.
2. Withdraw.
3. Quit.
What would you like to do: 2
How much would you like to withdraw: -0.5
Enter your pin: 1077
Error withdrawing funds.
Account details:
Name: Philip J. Fry
Age: 25
Balance: $0.93
Options:
1. Deposit.
2. Withdraw.
3. Quit.
What would you like to do: 2
How much would you like to withdraw: 0.5
Enter your pin: 1234
Error withdrawing funds.
Account details:
Name: Philip J. Fry
Age: 25
Balance: $0.93
Options:
1. Deposit.
2. Withdraw.
3. Quit.
What would you like to do: 2
How much would you like to withdraw: 0.5
Enter your pin: 1077
Account details:
Name: Philip J. Fry
Age: 25
Balance: $0.43
Options:
1. Deposit.
2. Withdraw.
3. Quit.
What would you like to do: 4
Invalid entry.
Account details:
Name: Philip J. Fry
Age: 25
Balance: $0.43
Options:
1. Deposit.
2. Withdraw.
3. Quit.
What would you like to do: 3
Thank you for banking with University Bank.
Acknowledgement
This laboratory assignment was developed by Drs. Roby Velez and Saikath Bhattacharya.