Before continuing on, make sure you’re caught up on the lectures through 6/13. Also make sure to pull the starter code.
In this assignment you will be implementing a version of a HashMap in order to create your own password manager.
A password manager is an application designed to store and manage someone’s passwords. The #1 rule of password security is to not reuse passwords. Whenever Safari or Chrome recommends those strong password filled with random letters and numbers, folks often opt not to use them for fear of not remembering them later. However with a password manager, you can use strong passwords without having remember them all. All it takes is 1 master password for the password manager, and then you can access all of your stored passwords.
Your PasswordManager
will be an implementation of the Map.java interface provided in the ex12
package. Account.java
is how we will represent an entry into the PasswordManager
. The method descriptions in Map.java
explain the logic you will implement in PasswordManager.java
. The key in the Map will be the name of the website you are making an account for, and the value will be the password you set. Your HashMap will be stored in an Account[]
of size 50, and you will use the hashing into lists method to handle collisions (AKA chaining). Your chaining scheme should insert at the head of the list.
The hashing algorithm you will be using to determine what index to store an Account
object is actually something built in to every object in Java: the hashcode()
method. Calling hashcode
on an object will return an int
that is computed using a hashing algorithm and properties of the object. While this number is not guaranteed to be unique, it is usually quite random, but keep in mind it may be larger than the size of the array. This number can also be negative so be sure to take the absolute value of it.
As of right now, 10 points for the user interface will be manually graded. I will let you know if I update the autograder to change this. The interface for the PasswordManager
will be a command line application that uses a Scanner
to read inputs. The code for the input output logic should all go in the main method in Main.java
. The Scanner
and PasswordManager
object are already created for you.
Upon running your program, your PasswordManager
should print “Enter Master Password”. Change the value of the variable MASTER_PASSWORD
in PasswordManager.java
to any String
of your choosing. If the entered password does not match the password saved in the MASTER_PASSWORD
variable, reprint “Enter Master Password” until the correct password is entered.
Once they are given access, the user should be able to enter one of the following phrases:
If something other than these 7 phrases are entered, print “Command not found” and wait for another command.
After each case, excluding “Exit”, they can enter another phrase. If they enter “Exit”, they get reprompted to enter the master password. Below is a control flow diagram to help visualize the logic.
===================
Based on which phrase is entered, you should call one of the methods in your PasswordManager
using the entered parameters. For each command, the user should be able to input the command name, and the needed parameters in the correct order. Here are the guidelines for using commands with parameters. Not that “Get accounts” and “Exit” do not have any parameters.
New password:
input:
New password
<Website Name>
<Password>
output:
New password added
Get password:
input:
Get password
<Website name>
output:
Password does not exist || <the account's password>
Delete account:
input:
Delete Account
<Website name>
output:
Account deleted || <Account does not exist>
Check duplicate password
input:
Check duplicate password
<password>
output:
No account uses that password ||
<Websites using that password:
website1
website2>
Get accounts:
input:
Get accounts
output:
Your accounts:
<account1
account2
account 3 etc.>
Generate random password:
input:
Generate random password
<Length of password (should be an int)>
output:
<generated password>
===================
Below is an example sequence of expected inputs and outputs, where the master password is password123.
Enter Master Password
password
Enter Master Password
password123
New password
facebook
mypassword
New password added
New passsword
instagram
mypassword
New password added
fake command
Command not found
Get password
facebook
mypassword
Get password
twitter
Account does not exist
Check duplicate password
mypassword
Websites using that password:
facebook
instagram
Check duplicate password
password789
No account uses that password
Generate random password
10
Zq9CZ9noe4
New password
facebook
Zq9CZ9noe4
New password added
Get accounts
Your accounts:
facebook
instagram
Delete account
facebook
Account deleted
Delete account
snapchat
Account does not exist
Exit
Enter Master Password
“Push” your work up to GitHub for backup. By creating “commits”, which you can think of as versioned checkpoints in your workspace, you are not at risk of losing your work. It’s easy to revert back to an old version or to restore your entire workspace on a different computer.
main
branch, and needs to be pushed to your remote backup.USERNAME
with your GitHub username:
https://github.com/comp210-ss1-24/summer210-workspace-USERNAME
As of right now, 10 points for the user interface will be manually graded. I will let you know if I update the autograder to change this.
All that’s left now is to hand-in your work on Gradescope for grading.
Before doing so, you need to know that before an assignment’s deadline you can resubmit work as many times as you need to without penalty. Portions of assignments are autograded and will provide near-immediate feedback. We want you to resubmit as many times as it takes you in order to earn full autograding credit!
Login to Gradescope and select the assignment named “EX12 - HashMaps” You’ll see an area to upload a zip file. To produce a zip file for autograding, return back to IntelliJ.
Along the bottom of your window, you should see an option to open a terminal integrated into IntelliJ.
Type the following command (all on a single line):
./submit.sh ex12
In the file explorer pane, look to find the zip file named “ex12_submission.zip”. The script will call it an ex12 submission since that is the package we zipped. If you right click on this file “Open in -> Finder” on Mac, the zip file’s location on your computer will open. Upload this file to Gradescope to submit your work for this exercise.
We are working on rewriting the script to work for Windows! Until then, please navigate to your course workspace in a File Explorer window. Then right click on the src
folder in your exercises directory and compress the directory into a zip folder. You can name it “ex12_submission.zip”
When you upload it to Gradescope, please delete any files that showed up in the src/
folder that were not actually part of ex12
.