Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@
<groupId>com.zipcodewilmington</groupId>
<artifactId>Dicey-Lab</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>


</project>
18 changes: 18 additions & 0 deletions src/main/java/Bins.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
import java.util.Map;
import java.util.HashMap;


public class Bins {
Map<Integer, Integer> mapOfBins = new HashMap<>();


public Bins(int lowestBinNumber, int highestBinNumber) {

for (int i = lowestBinNumber; i <= highestBinNumber; i++) {
mapOfBins.put(i, 0);
}
}
public Integer getBin(int binNumber) {
return mapOfBins.get(binNumber);



}

}
20 changes: 20 additions & 0 deletions src/main/java/BinsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import org.junit.Test;

import static org.junit.Assert.*;

public class BinsTest {


@Test
public void getBin() {
//given
Bins bins = new Bins(2, 12);
//When
int actual = bins.getBin(4);

//Then
assertEquals(0, actual);
}


}
34 changes: 34 additions & 0 deletions src/main/java/Dice.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
import java.util.Random;

public class Dice {

private Integer numberOfDice;
private Integer rollResult;
private Random random = new Random(3);
private int seed;

public Dice (Integer numberOfDice) {
this.numberOfDice = numberOfDice;
this.rollResult = rollResult;
}
public Dice(Integer numberOfDice, int seed) {
this.numberOfDice = numberOfDice;
this.seed = seed;
}

public Integer tossAndSum() {
Integer rollSum = 0;
for(int i = 0; i < numberOfDice; i++) {
rollResult = random.nextInt(6) + 1;
rollSum += rollResult;
}
return rollSum;
}
public Integer tossAndSumWithSeed() {
Integer rollSum = 0;
for(int i = 0; i < numberOfDice; i++) {
rollResult = random.nextInt(6) + 1;
rollSum += rollResult;
}
return rollSum;
}



}
21 changes: 21 additions & 0 deletions src/main/java/DiceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import org.junit.Assert;
import org.junit.Test;


class DiceTest {

@Test
public void tossAndSum() {
//given
Dice dice = new Dice(2);
//When
int actual = dice.tossAndSum();
//then

Assert.assertTrue(actual < 12 && actual > 2);

}



}