-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIdea.java
68 lines (55 loc) · 1.45 KB
/
Idea.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
/*
* Noah Garrison and Abhijeet Pradhan
* COM212
* Final Project
* 14 May 2018
*
* Idea class: Keeps track of Idea and all related variables
*/
public class Idea{
//Variables
private int id;
private int rating;
private String description;
private String owner;
private String email;
//List holds emails of user who have voted for this idea
private SinglyLinkedList <String> voters;
//Constructor takes required fields to create idea
public Idea(int i, int j, String owner, String k) {
id = i;
rating = j;
description = k;
this.owner = owner;
voters = new SinglyLinkedList<String>();
}
//getId method returns idea id
public int getId(){
return id;
}
//getRating method returns idea rating
public int getRating(){
return rating;
}
//setEmail method allows user to set idea owner's email
public void setEmail(String email){
this.email = email;
}
//getEmail method returns email of idea owner
public String getEmail(){
return email;
}
//addVoter method adds the email of a user who has voted for the idea to voters list
public void addVoter(String email){
voters.addLast(email);
rating++;
}
//checkVoters method returns true if user (identified by email) has already voted for the idea
public boolean checkVoters(String email){
return voters.isInList(email);
}
//toString method returns idea in orderly way
public String toString(){
return id + " | " + rating + " | " + description + "\n";
}
}