辅导案例-TCSS 305-Assignment 1

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
1

TCSS 305 Programming Practicum
Assignment 1: Login/Registration for Rentz
Value: 10% of the course grade
Due: Monday, 27 January 2020, 23:59:00

Program Description:

Assignment 0, Assignment 1, 2, 3, 4 aim to develop Rentz, a vehicle rental system. You will incrementally
build your code for each assignment, i.e., your Assignment 1 will be built using the code that you submitted for
Assignment 0. Make sure you finish every assignment on time, so that your future submissions remain
unaffected. Assignment 1 focuses on developing a Registration and login system for Rentz.

Using Previous Code:
1. You have already submitted the project “username-rentz-0” which is present in your project
explorer to the SVN repository. Since you are going to build on the same code, you will need to rename
your project. However, you will need to disconnect from the SVN repository before you rename your
project.
2. Right-click on the project name on Package Explorer (in this case, “username-rentz-0”) and select
“Team / Disconnect”. There will be a dialog box, select “Also delete the SVN meta-
information from the file system” option and click “yes”. The project will be disconnected
from SVN repository.


3. Save the contents of your project to a local drive. Right-click on the project name, select Export ->
Archive file, then click “Next>”. In “To Archive File” enter the location and name of the
archive that you want to create and click “Finish”. Your project will be saved in the given location.
4. To rename the project, right-click on the project name and select “Refactor->Rename”. You
should rename the project to “username-rentz-1”, where “username” is your UWNetID. Once you
have re-named the project, you can make changes to the code as needed. To submit the new code, i.e.,
“username-rentz-1” to SVN follow steps 1-6 under “Submitting your project to the SVN server”
given in “hw0.pdf”. While following steps 1-6 from the document, replace “username-rentz-0” by
the new project name “username-rentz-1”.



2

Implementation Guidelines:

NOTE: Do not change the name of the class fields and the methods as well as the method signatures. Do not
add any extra fields other than static final constants. You can have different names for method
parameters. You can define extra utility methods but should not remove any of the existing code. You should
add appropriate access modifiers for the class members. Portions of the code have already been given to you.
Your task is to complete the implementation of the User and Registration classes to make the code work.

User: this class represents information about the registered user. The outline of the class is already present in
model/User.java
Field Data Type Description
myName String It represents the username
myPassword String It represents the password for login
myVIPStatus boolean It represents if a User is a VIP member or not

Method Parameters Return
Type
Description
Parameterized
Constructor
String
theName

String
thePassword
• Constructor with username and password. This
constructor is called when a User object is created only
with username and password. Default value for
myVIPStatus = false should be assigned.

The constructor should implicitly throw
NullPointerException for null parameters and
should explicitly throw
IllegalArgumentException if the username or
password is an empty string
Parameterized
Constructor
String
theName

String
thePassword

boolean
theVIPStatus
Constructor with username, password and VIPStatus

The constructor should throw
NullPointerException for null parameters and
should throw IllegalArgumentException if the
username or password is an empty string
getMyName String Returns the username
getMyPassword String Returns the password
getMyVIPStatus boolean Returns the VIP Status
toString String Returns the String representation of the User Object.
The format of the string should be
classname (username, password, VIPStatus)
e.g. User (TCSS305, 305, true)
equals Object
theOtherObje
ct
boolean Checks if theOtherObject is equal to this object
based on the username, password, VIPStatus fields
hashcode int Creates the hascode using username, password and
VIPStatus fields
3

Registration: this class displays options for registration or login. It adds a new user to the list of registered
users and saves it to file. It also verifies if the username and password of an existing user is correct during login.
Field Data Type Description
USERFILE_NAME static
final
String
It represents the file which saves the list of registered users consisting of
user name, password, VIPstatus for each of them. Do not change the value
of this field. The file is present under resources/registeredusers.txt
myUserList final
MapUser>
HashMap representing the list of registered users, where key is the
username and value is the User object

Method Parameters Return Type Description
Parameterless
Constructor
Loads the list of previously registered user from the file.

getMyUserList MapUser>
Returns myUserList
printSignin void Prints user options in the console output. Displays option
for new registration or login.

For new user registration, it accepts user name, password
and VIPStatus from console. It calls the register
function to verify if registration is successful or one
needs to re-enter the username, password and VIPStatus.

For user login, it checks accepts username and password
from console. It calls login method to check if the
credentials are correct or if they need to be re-entered.

The exact format of the output that is required for
implementing the printSignin function is shown
using screenshots below.
login String
theUserName

String
thePassword
boolean Checks if the username is present in the list of registered
users. If the user is already present and if the password
matches the entered password, it returns true.
Otherwise, it returns false.

The parameters should be checked for null values and
should throw NullPointerException for null
parameters implicitly and should throw
IllegalArgumentException if the username or
password is an empty string
register User
theUser
boolean Adds theUser to myUserList
Write the registered user to file. The information of
every registered user should be “added” to the file
resources/registeredusers.txt. To write to the file use the
writeUserToFile(final String theFile,
final User theUser) method from the
Fileloader class present in the utility package

4

The parameters should be checked for null values and
should throw NullPointerException for null
parameters implicitly
clear void Clears and removes all elements in myUserList
toString String Returns the String representation of the Registration
Object. The format of the string should be
Registered UserList
{key1=value1,key2=value2}

e.g., Registered UserList {tcss305=User
(tcss305, 305, true), athirai= User
(athirai, 1234, true)}

Your program should display the exact output as shown below
1. When you run RentalMain.java you should get the following output


2. When 1 is entered, the following should be displayed


3. After entering the user details for new registration, the following should be displayed If it is successful



5





4. If the username already exists (even though password, VIPStatus are different), the system asks for a
new username and password until a non-existing username and any password is entered.



5. When option 2 is selected, the following output should be displayed




6



6. When the username and password is entered correctly, the following should be displayed


7. When the username or password is entered in-correctly, the username and password should be re-
entered until the credentials are found to be correct

7

Extra Credit: Up to 5% extra credit can be earned by completing the following. The password does not
have any restrictions currently. If you want the user to enter password with restrictions Step 7 should display
“Password Does not Comply [….List the rules the password should follow]”, when a password that does not
comply with your rules is entered. The user should be allowed to re-enter a password until it complies with the
rules. You should enforce at least 5 rules of your own choice.
Submitting your executive summary:
The executive summary template will be provided to you in canvas. Download the file. Rename the executive
summary “executivesummary-username-rentz-1”, where username is your UWNetID. Fill and upload
the executive summary to canvas as the same WORD format. The grader will grade your submission based on
the executive summary as well as the project you submit to the SVN repository. If you do not submit either of
them, you will receive no grades.
Grading Rubric (Total 100 points, 105 possible with extra credit):
Task Max Score
Possible
Executive Summary -Submission on canvas with correct version number 5
Source Code – Submission to SVN 5
User class – correct fields as per guidelines 5
User class – correct access modifiers for fields and methods 5
User class – correct implementation of parameterized constructor1 5
User class – correct implementation of parameterized constructor2 5
User class – correct implementation of getName(), getMyPassword(), get MyVIPStatus() 5
User class – correct implementation of toString method 5
User class – correct implementation of equals method 5
User class – correct implementation of hashcode method 5
Registration class – correct implementation of toString() and clear() 5
Registration class –printSignin: display New Registration/Login option [code: 3, output: 2] 5
Registration class – printSignin (new registration): get user input for Username, password,
VIPStatus [code: 3, output: 2]
5
Registration class – printSignin, register: check if user already exists and print login
successful [code: 3, output: 2];
5
Registration class – printSignin, register: check if user already exists and print User already
exists until a correct username is entered [code: 3, output: 2]
5
Registration class –printSignin, login: get username and password and call login function to
check if successful [code: 3, output: 2]
5
Registration class –printSignin, login: get username and password and call login function
until an existing username and correct password is entered else display wrong credentials
[code: 3, output: 2]
5
Correct Project Name and Executive summary name 5
No Errors and Warnings (except reasonable ones which should be clearly explained in
executive summary)
5
Proper Java docs and Header comments 5
Extra Credit 5


Total (105 points possible with extra credit)


100

51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468