-
Notifications
You must be signed in to change notification settings - Fork 28
/
Recommendation.java
149 lines (122 loc) · 3.23 KB
/
Recommendation.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
public class Recommendation
{
/* Instance variable declarations go here, before constructors */
// STEP 1 of 4: Add one private instance variable
private int views;
private String description;
private String author;
private int likes;
private String imgLink;
private String comment;
private String[] commentList;
private int numOfRecommendations;
private int month;
private int day;
private int year;
private String date;
private int dislikes;
private boolean hasImage;
private int starRating;
/* No Argument Constructor - same name as Class, no return type */
public Recommendation()
{
// STEP 2 of 4: Set a default value for your instance variable.
// NOTE: If yr instance var is a String, do NOT set it to null or "".
// NOTE: If yr instance var is an Object, do NOT set it null. Construct that Object.
description = "This is a defult description";
views =0;
likes = 0;
month = 0;
day = 0;
year = 0;
date = "0/0/0";
author = "John Doe";
imgLink = "https://fl-1.cdn.flockler.com/embed/no-image.svg"
dislikes = 0;
hasImage = false;
numOfRecommendations = 0
comment = " ";
commentList = new String[0];
starRating = 0;
}
/* Method definitions go here, after constructors */
// STEP 3 of 4: Add one accessor method (getter) for your instance variable
public int getViews(){
return views;
}
public String getDesc() {
return description;
}
public int getLikes(){
return likes;
}
public String getImgLink(){
return imgLink;
}
public int getNumOfRecommendations(){
return numOfRecommendations;
}
public void setDate(int _month, int _day, int _year){
month = _month;
day = _day;
year = _year;
date = month + "/" + day + "/" + year;
}
public String getDate(){
return date;
}
public int getDislikes(){
return dislikes;
}
public boolean getHasImage(){
return hasImage;
}
public String getAuthor(){
return author;
}
public int getStarRating(){
return starRating;
}
// STEP 4 of 4: Add one mutator method (setter) for your instance variable
public void addViews(){
views =views+1;
}
public void setDesc(String _description) {
description = _description;
}
public void changeLikes(int newLikes) {
likes += newLikes;
}
public void setAuthor(String _author){
author = _author;
}
public void setImgLink(String _imgLink){
imgLink = _imgLink;
}
public String setComment(String newComment) {
commentList = Arrays.copyOf(commentList, commentList.length + 1);
commentList[commentList.length - 1] = newComment;
return commentList;
}
public String getComments() {
return Arrays.toString(commentList);
}
public void setNumOfRecommendations(int _numOfRecommendations){
numOfRecommendations = _numOfRecommendations
}
public void addDislike() {
dislikes += 1;
}
public void setHasImage(boolean _hasImage){
hasImage = _hasImage;
}
public void setStarRating(int _starRating){
if (_starRating < 0){
_starRating = 0;
};
if (_starRating > 10){
_starRating = 10;
};
starRating = _starRating;
}
}