diff --git a/src/Die.java b/src/Die.java index d538dc0..076eb43 100644 --- a/src/Die.java +++ b/src/Die.java @@ -1,11 +1,39 @@ package src; +import java.util.Random; public class Die { + private int faces; + private int value; + private boolean locked; + private Random random; - public Die (int eyes){ - + public Die(int faces) { + this.faces = faces; + this.locked = false; + this.random = new Random(); + roll(); } public void roll() { + if (!locked) { + value = random.nextInt(faces) + 1; + } + } + + public int getValue() { + return value; + } + + public void setLocked(boolean locked) { + this.locked = locked; + } + + public boolean isLocked() { + return locked; + } + + public void toggleLock() { + this.locked = !this.locked; } } +