Download - Backpack

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CSE201: Advanced Programming
Lab Assignment 3
Solution and Marking Scheme
There should be two java files submitted- Login_details.java andPerson.java and one of them should
also have another class defined called Incorrect_Credentials_Exception.
There is no Junit test file provided this time. Instead, there is a .java called SocialNetwork.java that
contains a main method that you have to run. Go through the rules in the question when the person
is expected to be logged in to perform a certain action.
Proceeding with the main method is as follows:









Creating the 5 Person objects creates 5 profiles that remain logged in until any object
logsout itself using p.log.logout().
For instance, p1 after adding 3 friends(p2,p3,p5) logsout .
Note that when a Person object adds a friend say p2 , the action is bidirectional i.e even the
p2 should add p1 in its friendlist.
p2 adds p4,p5 as friends.
p5 logsout
Now p5 attempts to add a friend but since p5 is logged out, the system should prompt him
to enter username and password(“har”,”har123”) on console. If incorrectly entered, the
Incorrect_Credentials_Exception should get thrown ask user to reenter the credentials until
correctly entered.
Once correctly logged in, p5 should proceed with adding p2,p3,p4 as friends. Ideally,since p2
is already p5’s friend it should not re-add it but if students have not taken care of it then it is
ok.
Now the p1’s friendlist is requested for in p1.getFriendList(); Since p1 was logged,
prompt for the credentials(“sid”,”sid”) and follow the same login procedure as previously
described.
Once logged in, the output should be
Friends of Siddharth:[Amit, Samit, Harsh]
Mutual friends of Siddharth and Harsh:[Amit, Samit] // this will proceed as p1
is logged in, note that p5 need not be logged in
Mutual friends of Siddharth and Amit:[Harsh] // this will proceed as p1 is
logged in, note that p2 need not be logged in




Now p2 logsout
p1.get_mutual_friends(p2)should proceed with
Mutual friends of Siddharth and Amit:[Harsh]
However, p2.getfirndlist() should prompt p2 to log in and the same login procedure
must follow.
Once logged in the output should be:
Mutual friends of Amit and Siddharth:[Amit, Samit, Harsh]
Final output on console(ignore the numbering):
Harsh expected to be logged in
1) Please enter your username:
har
Please enter your password:
har
2) com.iiitd.ap.lab3.Incorrect_Credentials_Exception
at com.iiitd.ap.lab3.Login_details.login(Login_details.java:74)
at com.iiitd.ap.lab3.Person.addFriend(Person.java:99)
at com.iiitd.ap.lab3.SocialNetwork.main(SocialNetwork.java:47)
3) Please enter your username:
har
Please enter your password:
har123
Siddharth expected to be logged in
4) Please enter your username:
sid
Please enter your password:
sid
5) Friends of Siddharth:[Amit, Samit, Harsh]
6) Mutual friends of Siddharth and Harsh:[Amit, Samit]
7) Mutual friends of Siddharth and Amit:[Harsh]
Amit expected to be logged in
8) Please enter your username:
am
Please enter your password:
am
9) com.iiitd.ap.lab3.Incorrect_Credentials_Exception
at com.iiitd.ap.lab3.Login_details.login(Login_details.java:74)
at com.iiitd.ap.lab3.Person.getFriendList(Person.java:136)
at com.iiitd.ap.lab3.SocialNetwork.main(SocialNetwork.java:63)
10)Please enter your username:
amit
Please enter your password:
qwerty
11)Friends of Amit:[Siddharth, Arun, Harsh]
12)Mutual friends of Amit and Siddharth:[Harsh]
Marking scheme [15 marks]

Running the scenario as described above. Each set of numbered lines carries 1mark. Note
that it is acceptable if instead of printing the stacktrace in line sets 2) and 9) they are
throwing an exception message but there should be some way to inform that an
Incorrect_Credentials_Exception has occurred at these points. [12 marks]

For the methods and fields in the submission, ensure that the access modifiers are as
specified in the javadoc. Eg. The password field in login_details class should only be private
and not public or any other.
Deduct 0.25 marks for each incorrect access modifier. Note that package private implies the
default access modifier.[3marks]
Note that here instead of giving marks, the approach is to deduct marks for anything
incorrect.