-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearch_Popularity.java
More file actions
63 lines (47 loc) · 1.54 KB
/
Search_Popularity.java
File metadata and controls
63 lines (47 loc) · 1.54 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
/**
*A class that represents the search popularity for the candidate
*Search popularity is simply a relative number of popularity where 100 is the highest
*includes the date
*/
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Search_Popularity {
/////////////////fields//////////////////////
/** the date of the data as a date type */
private Date date;
/** the candidate result */
private int candidateResult;
/////////////////constructors////////////////////
/**
*A constructor that creates a new search_popularity object
*@param date the date of the sample
*@param candidateResult the result for the candidate
*/
public Search_Popularity(String date, String candidateResult)
{
//Convert date to date data_type
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yy");
try {
Date dates = formatter.parse(date);
this.date=dates;
}
catch (ParseException e) {
e.printStackTrace();
}
this.candidateResult=Integer.parseInt(candidateResult);
}
///////////////////Methods///////////////////////////////
//A toString Method
public String toString()
{
return("This search analysis occurred on " +this.date + "." + " The candidate's result was " + this.candidateResult +".");
}
//Get Methods for all instance variables
public Date getDate() {
return this.date;
}
public int getcandidateResult() {
return this.candidateResult;
}
}