From 36da98836dabd99e7a65ec843e508fd63d48fe3e Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Thu, 18 Feb 2021 11:26:25 -0500 Subject: [PATCH] Add EightDie --- Project/EightDie.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Project/EightDie.java diff --git a/Project/EightDie.java b/Project/EightDie.java new file mode 100644 index 0000000..9683682 --- /dev/null +++ b/Project/EightDie.java @@ -0,0 +1,32 @@ +import java.util.*; + +public class EightDie extends MyDie implements Comparable { + + public EightDie() { + // set default values + myValue = (int) (Math.random()*8)+1; + rand = new Random(); + } + + public void roll () { + myValue = rand.nextInt(8) + 1; + } + + public int getValue() { + return myValue; + } + + + // set the random number generator seed for testing + public void setSeed(int seed) { + rand.setSeed(seed); + + } + + // allows dice to be compared if necessary + public int compareTo(Object o) { + EightDie d = (EightDie) o; + return getValue() - d.getValue(); + } + +}