-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
65 lines (55 loc) · 1.63 KB
/
Copy pathUser.java
File metadata and controls
65 lines (55 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Class: User
*
* @Author: Kabir Bhakta
* @Student Num: 7900098
* @Purpose: This class is used to manipulate and store user data and information.
*/
public class User extends ListItem
{
//instance variables
private String usrId; //user id
List reportList; // all edits user made
ReportItem report; //report of the edits
//constructor
public User( String id ){
usrId = id;
reportList = new List();
}
//returns the string of user id
public String getName(){
return usrId;
}
/*
* This method used to compare user id
* Returns true if both the ids are same
* Returns false if both the ids are distinct
*/
public boolean equals(ListItem item) {
boolean found = false; //return variable
if( usrId.equals(item.getName()) ){
found = true;
}
return found;
}
//adds report to reportList
public void addReport(ReportItem repo){
reportList.insert(repo);
}
//prints our report list used for USERREPORT command
public String getReport(){
String str = "";
List.ListIterator curr = reportList.iterator();
String header = "Report for userID: "+usrId+"\n------------------------------\n";
while(curr.hasNext()){
ReportItem currReport = (ReportItem)curr.next();
str += currReport.printUReport();
}
String footer = "\n------------------------------\n";
return header + str + footer;
}
//CLone the user
public User clone(){
return new User(usrId);
}
}