// ─────────────────────────────────────────────────────────────────────────────
// Magic 8 Ball Demo — Java
// Cross Training: Conditional Logic (if/else)
// Based on chooseMessageType() from Magic8Ball2026-07-05-Stg6
// ─────────────────────────────────────────────────────────────────────────────

import java.util.Random;   // Random is a class in java.util — must be imported

public class Magic8BallDemoDriver {

    // Probability weights — must sum to 1.0
    static final double PROB_POSITIVE = 0.35;   // 35%
    static final double PROB_NEGATIVE = 0.35;   // 35%
    static final double PROB_VAGUE    = 0.20;   // 20%
    // snarky = remaining 10%

    public static String chooseMessageType(double roll) {
        double cutoff1 = PROB_POSITIVE;                          // 0.35
        double cutoff2 = PROB_POSITIVE + PROB_NEGATIVE;          // 0.70
        double cutoff3 = cutoff2 + PROB_VAGUE;                   // 0.90

        if (roll <= cutoff1) {
            return "positive";
        } else if (roll <= cutoff2) {
            return "negative";
        } else if (roll <= cutoff3) {
            return "vague";
        } else {
            return "snarky";    // remaining 10%
        }
    } // end chooseMessageType

    public static void main(String[] args) {
        Random rng = new Random();       // Random is a class — must instantiate
        double roll = rng.nextDouble();  // 0.0 (inclusive) to 1.0 (exclusive)
        String type = chooseMessageType(roll);
        System.out.printf("Roll: %.3f => %s%n", roll, type);
    } // end main

} // end class Magic8BallDemoDriver
