// Magic8Ball Example // Source code file: Prediction.java // When linear layout is clicked, display randomly one // of the 20 Magic8Ball predictions. package it372.ssmith.magic8ball; import java.util.ArrayList; import java.util.Random; public class Prediction { private ArrayList prediction = new ArrayList<>( ); private Random r = new Random( ); public Prediction( ) { // Default constructor that creates // Prediction object, but nothing else. } public void addPrediction(String p) { // Add prediction to the arraylist // of possible Magic8Ball predictions. prediction.add(p); } public String getPrediction( ) { // Choose random index for next prediction. int n = r.nextInt(prediction.size( )); // Return nth prediction. return prediction.get(n); } }