Kotlinlearncs.online LogoJava
Return to List

Test Writing: Mario Bricks

Imported By: Geoffrey Challen
/ Version: 2022.7.0

Let's complete our own version of the classic Mario Bricks assignment from CS50!

Write a method named makeBricks that accepts a single int and returns a String containing a Mario pyramid of # characters. For example, given the input 4, that would look like this:

   #
  ##
 ###
####

You can find more examples and some hints here. The int passed to makeBricks will be positive. And note that your result should end with a newline character.

Test Design Challenge

You're challenge is to write tests for this problem described above.

  • Provide a method named test that accepts no arguments and does not return a value.
  • If the implementation of the class described above is incorrect, your test method should throw an exception.
  • If it is correct, do not throw an exception.
  • You may want to use Java's assert method