Java Reference
In-Depth Information
pass = screenVal >= threshold;
break;
case BETA:
screenVal = Math.random() * 2;
pass = screenVal <= threshold;
break;
}
System.out.println(stock + ": "
+ screen.toString() + " = " + screenVal);
return pass;
}
public static void screen(List<String> stocks, Screen
screen, double threshold) {
Iterator<String> iter = stocks.iterator();
while (iter.hasNext()) {
String stock = iter.next();
if (!screen(stock, screen, threshold)) {
iter.remove();
}
}
}
public static void main(String[] args) {
List<String> stocks = new ArrayList<>();
stocks.add("ORCL");
stocks.add("AAPL");
stocks.add("GOOG");
stocks.add("IBM");
stocks.add("MCD");
System.out.println("Screening stocks: " + stocks);
if (stocks.contains("GOOG") &&
!screen("GOOG", Screen.BETA, 1.1)) {
Search WWH ::




Custom Search