Commit 37a5e049 authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch1] Changed the random number generator because I don't like all the...

[Ch1] Changed the random number generator because I don't like all the multiplying and casting in Math.random
parent 4b9943cb
Loading
Loading
Loading
Loading
+4 −3
Changes for src/main/java/ch1/PhraseOMatic.java: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -16,9 +16,10 @@ public class PhraseOMatic {
    int threeLength = wordListThree.length;

    // generate three random numbers
    int rand1 = (int) (Math.random() * oneLength);
    int rand2 = (int) (Math.random() * twoLength);
    int rand3 = (int) (Math.random() * threeLength);
    java.util.Random randomGenerator = new java.util.Random();
    int rand1 = randomGenerator.nextInt(oneLength);
    int rand2 = randomGenerator.nextInt(twoLength);
    int rand3 = randomGenerator.nextInt(threeLength);

    // now build a phrase
    String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];