-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCandidateBasicInput.java
More file actions
118 lines (117 loc) · 4.29 KB
/
CandidateBasicInput.java
File metadata and controls
118 lines (117 loc) · 4.29 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
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
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class CandidateBasicInput {
private static ArrayList<Candidate> candidates = new ArrayList<Candidate>();
public static void JoeBiden(){
String name = "Joseph R. Biden Jr.";
String[][] years = new String[][] {{"Delaware Senator", "36"}, {"Vice President", "8"}};
String slogan = "Our Best Days Still Lie Ahead";
boolean qual = true;
int poll = 1;
ArrayList<String> issues = new ArrayList<String>();
BufferedReader br;
try {
File file = new File("JoeBiden.txt");
br = new BufferedReader(new FileReader(file));
int i = 0;
String s;
while((s = (br.readLine())) != null) {
issues.add(i, s);
i++;
}
i = 0;
br.close();
}
catch(IOException e) {
System.out.println("File not found.");
}
String[] news = new String[3];
news[0] = "https://www.nytimes.com/2019/10/26/us/politics/joe-biden-campaign-fundraising.html";
news[1] = "https://nypost.com/2019/10/26/brother-of-sandy-hook-victim-calls-out-biden-for-"
+ "lying-in-campaign-ad/";
news[2] = "https://www.washingtonpost.com/politics/ap-interview-biden-confident-of-prospects-"
+ "in-south-carolina/2019/10/26/54ef6f20-f816-11e9-b2d2-1f37c9d82dbb_story.html";
Candidate JoeBiden = new Candidate(name, slogan, qual, years, news);
JoeBiden.setIssues();
JoeBiden.setPoll(poll);
JoeBiden.setStances(issues);
candidates.add(JoeBiden);
}
public static void ElizabethWarren(){
String name = "Elizabeth Warren";
String[][] years = new String[][] {{"Delaware Senator", "36"}, {"Vice President", "8"}};
String slogan = "Our Best Days Still Lie Ahead";
boolean qual = true;
int poll = 1;
ArrayList<String> issues = new ArrayList<String>();
BufferedReader br;
try {
File file = new File("JoeBiden.txt");
br = new BufferedReader(new FileReader(file));
int i = 0;
String s;
while((s = (br.readLine())) != null) {
issues.add(i, s);
i++;
}
i = 0;
br.close();
}
catch(IOException e) {
System.out.println("File not found.");
}
String[] news = new String[3];
news[0] = "https://www.nytimes.com/2019/10/26/us/politics/joe-biden-campaign-fundraising.html";
news[1] = "https://nypost.com/2019/10/26/brother-of-sandy-hook-victim-calls-out-biden-for-"
+ "lying-in-campaign-ad/";
news[2] = "https://www.washingtonpost.com/politics/ap-interview-biden-confident-of-prospects-"
+ "in-south-carolina/2019/10/26/54ef6f20-f816-11e9-b2d2-1f37c9d82dbb_story.html";
Candidate ElizabethWarren = new Candidate(name, slogan, qual, years, news);
ElizabethWarren.setIssues();
ElizabethWarren.setPoll(poll);
ElizabethWarren.setStances(issues);
candidates.add(ElizabethWarren);
}
public static void createIssueMap(int issueNum) {
ArrayList<String> issueStances = new ArrayList<String>();
for(int i = 0; i < candidates.size(); i++) {
issueStances.add(i, candidates.get(i).getStances().get(issueNum));
}
HashMapCreator<String> issueMap = new HashMapCreator<String>(candidates, issueStances);
String title = candidates.get(0).getIssues().get(issueNum);
issueMap.createMap();
issueMap.printAll(title);
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
JoeBiden();
ElizabethWarren();
System.out.println("Candidates: ");
for(int i = 0; i < candidates.size(); i++) {
System.out.println((i+1) + ". " + candidates.get(i).getName());
}
int num = 100;
while(num != 0) {
System.out.println("If you want to know more about a candidate, enter their number, otherwise"
+ " enter 0 to continue.");
num = input.nextInt();
if(num != 0) {
candidates.get(num - 1).printAll();
}
}
num = 100;
while(num != 0) {
System.out.println("If you want to know more about where all the candidates stand on issues,"
+ " enter the issue number you'd like to see the distribution for, "
+ "or enter 0 to continue.");
num = input.nextInt();
if(num != 0) {
createIssueMap(num - 1);
}
}
}
}