{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

WurfelSpielTester_Solutions

# WurfelSpielTester_Solutions - import...

This preview shows pages 1–2. Sign up to view the full content.

Sheet1 Page 1 import junit.framework.TestCase /** Contains methods to test methods of class WuerfelSpiel. */ public class WurfelSpielTester extends TestCase { /** * Test throwDie. Do this by calling it 200 times and making sure: (1) Each value returned is in the range 1..6. (2) All values in 1..6 are returned by at least one call. */ public void testThrowDie() { /** Boolean array c should be used as follows. For each of the 200 times that WurfelSpiel.throwDie() is called and produces a value i (say) in the range 1..6, set c[i] to true. After calling WurfelSpiel.throwDie() 200 times, check (using assertEquals calls) whether all the values in c are true. */ boolean[] c= {true, false, false, false, false, false, false} //boolean[] c= new boolean[200] // inv: k calls on throwDie have been made. All of them have been in // the range 1..6 (unless the call on assertEquals failed). For // each i, c[i] is true if and nly if one of the calls produced the value i. for (int k= 0 k != c.length k= k+1) { int i= WurfelSpiel.throwDie() if ( 1 <= i && i <= 6){ c[k]= true

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern