From the course: Programming Foundations: Test-Driven Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

✓ Solution: Performance

✓ Solution: Performance - Java Tutorial

From the course: Programming Foundations: Test-Driven Development

Start my 1-month free trial

✓ Solution: Performance

(upbeat music) - [Instructor] In this challenge, we are testing two variables, remaining trials and the score. When a new round is started, that is a new word is fetched, then the remaining trial count is set to a constant, say max trials. And after one guess made by the player, it should be reduced by one. For score, it should be zero in the beginning and increase only when a correct guess is made as per the formula shown here. So let us start with remaining trials. So I am in test hangman. Here I will write my next test case, as void test, remaining trials, before any guess. At this point I would use hangman and fetch a word. And this the indication that I am just starting a new round. And then I say, assert equals. And I expect a constant, let's say max trials in hangman. Which should be equal to hangman's remaining trials variable. Now to resolve these issues, I will first create the constant. It says public static final. I'll make this as end. And set it to ten. Then for…

Contents