-
Notifications
You must be signed in to change notification settings - Fork 0
/
TickerOptions.java
65 lines (59 loc) · 1.71 KB
/
TickerOptions.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
/**
* The class stores the collection of ticker options,
* and is able to parse tickers' strings to build a correct URL
*
* @Author: Junxiang Chen
* @RegistrationNumber: 180127586
* @Email: jchen115@sheffield.ac.uk
*/
/*
import dependencies
*/
import java.util.Set;
import java.util.TreeSet;
/**
* the constructor function
*/
public class TickerOptions {
/*
declare and define class variables
*/
private static String[] tickers = {
"FOX (U.S.: Nasdaq) - 21st Century Fox Inc. Cl B",
"AAPL (U.S.: Nasdaq) - Apple Inc.",
"MSFT (U.S.: Nasdaq) - Microsoft Corp.",
"AMZN (U.S.: Nasdaq) - Amazon.com Inc.",
"GOOGL (U.S.: Nasdaq) - Alphabet Inc. Cl A",
"TWTR (U.S.: NYSE) - Twitter Inc.",
"SNE (U.S.: NYSE) - Sony Corp. ADR",
"DIS (U.S.: NYSE) - Walt Disney Co.",
"F (U.S.: NYSE) - Ford Motor Co.",
"RYCEY (U.S.: OTC) - Rolls-Royce Holdings PLC ADR"
};
public static Set<Ticker> tickerOptions = new TreeSet<>();
/*
define class method
*/
/**
* add Ticker objects to the TreeSet
*/
public static void addOptions() {
for (String ticker : tickers) {
tickerOptions.add(new Ticker(ticker));
}
}
/**
* get string of each Ticker objects in the tickerOptions object
*
* @return String[], a list of strings
*/
public static String[] iterOptions() {
String[] sortedTickers = new String[tickers.length];
int index = 0;
for (Ticker ticker : tickerOptions) {
sortedTickers[index] = ticker.getName();
index = index + 1;
}
return sortedTickers;
}
}