From the course: Practical Test-Driven Development for Java Programmers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Using TDD to safely fix bugs

Using TDD to safely fix bugs

- [Instructor] Well, we need to know how to deal with the letter X. Now I'll leave you to go and read the Wikipedia page if you wish to. But what you'll find is that when we do this calculation here, we're taking each value and multiplying it by a number. If it's the letter X, then it should have the value of 10. So when we do this line here, we need to check if it's an X and if it is, add the number 10. Now actually, what we can do is incorporate this within the if statement. So what we'll do is say, if this is a nine and it's the letter X, then we want to add 10 to our total. I should maybe point out that you don't need to multiply it by anything because the last number is always multiplied by one. Actually let's just work through this calculation to make sure that we understand it. I've got on screen here the ISBN number that we're trying to check. And we're going to multiply each of the digits by these numbers here. And if you remember, I said that the last digit counted for 10…

Contents