-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.java
78 lines (65 loc) · 1.91 KB
/
User.java
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
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Noah Garrison and Abhijeet Pradhan
* COM212
* Final Project
* 14 May 2018
*
* User class: Class for Users/Students in our program
*/
public class User {
//variables keep track of personal user data
private String firstName;
private String lastName;
private String email;
//ListDQueue keeps track of the users five most recent ideas
private ListDQueue <Idea> ideaList = new ListDQueue<Idea>();
public User() {}
//Constructor creates user, assigns variables values
public User(String i, String j, String k) {
firstName = i;
lastName = j;
email = k;
}
//method returns list of user's ideas
public ListDQueue <Idea> listOfIdeas(){
return ideaList;
}
//method returns user's email
public String email(){
return email;
}
//methods adds a new idea to user's idea list
public void addIdea(String idea) {
String owner = firstName + " " + lastName;
Idea suggestion = new Idea(0, 0, owner, idea);
ideaList.addLast(suggestion);
if (ideaList.size() > 5)
ideaList.removeFirst();
}
//Method adds an idea which already has a rating and id to the idea list
public Idea addIdeaRated(String idea, int id, int rating) {
String owner = firstName + " " + lastName;
Idea suggestion = new Idea(id, rating, owner, idea);
ideaList.addLast(suggestion);
if (ideaList.size() > 5)
ideaList.removeFirst();
return suggestion;
}
//toString method returns user's name and email as a string
public String toString(){
String userInfo = firstName + " " + lastName + "\n" + ideaList.toString();
return userInfo;
}
}
class userTest{
public static void main(String [] args){
User abhijeet = new User("Abhijeet", "pradhan", "apradha1@conncoll.edu");
abhijeet.addIdea("Host a concert");
abhijeet.addIdea("hello");
abhijeet.addIdea("hello");
abhijeet.addIdea("hello");
abhijeet.addIdea("hello");
abhijeet.addIdea("hello");
System.out.println(abhijeet);
}
}