O'Reilly logo

Test-Driven Java Development - Second Edition by Viktor Farcic, Alex Garcia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Requirement 2 – introducing discs

This is the implementation for the second requirement.

Players introduce discs on the top of the columns. An introduced disc drops down the board if the column is empty. Future discs introduced in the same column will stack over the previous ones.

We can split this requirement into the following tests:

  • When a disc is inserted into an empty column, its position is 0
  • When a second disc is inserted into the same column, its position is 1
  • When a disc is inserted into the board, the total number of discs increases
  • When a disc is put outside the boundaries, a Runtime Exception is thrown
  • When a disc is inserted into a column and there's no room available for it, then a Runtime Exception is thrown

Also, these other ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required