Kotlinlearncs.online LogoJava
Return to List

Test Writing: Drop Bear Safety

Created By: Geoffrey Challen
/ Version: 2026.2.0

The drop bear is a fearsome creature from Australian folklore -- a large, carnivorous koala that drops from trees onto unsuspecting tourists. (Don't worry, they're not real... probably.)

Create a function called dropBearDanger that accepts three Boolean parameters:

  • hasVegemite: whether you have Vegemite behind your ears (a well-known drop bear repellent)
  • underEucalyptus: whether you are standing under a eucalyptus tree
  • isNighttime: whether it is nighttime

Return a String indicating your danger level:

  • If hasVegemite is true, return "Safe" -- Vegemite always protects you, regardless of other conditions.
  • If underEucalyptus and isNighttime are both true, return "Extreme danger!".
  • If either underEucalyptus or isNighttime is true (but not both), return "Moderate danger".
  • Otherwise, return "Low danger".

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 Kotlin's assert or check methods

Related Lessons

Stuck? You may find these lessons helpful:

Report a Problem

Attribution must link to this page: https://www.learncs.online/testtesting/kotlin/drop-bear-safety/[email protected]