Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Interface | Interface
Java OOP

Challenge: InterfaceChallenge: Interface

Task

For you, two interfaces have been created: Human and Animal, as well as one class – Werewolf. Your task is to inherit both interfaces in the Werewolf class and then implement their methods. In the Werewolf class, the comments above indicate how you should override these methods. A werewolf is both a human and an animal, so it has a method called transform(). You should also use the boolean value isHumanForm in the methods as instructed. If the task seems difficult, feel free to use the Hint and Solution buttons to analyze the solution!

Link to the task: GitHub
Warning
Do not modify the transform() method and do not edit the fields.
  • You have interfaces and a class. Before you start working, familiarize yourself with these interfaces and the class.
  • In the Werewolf class, you should implement two interfaces – Human and Animal. Do this using the syntax implements Human, Animal.
  • Override the methods using the @Override annotation from both interfaces.
  • The speak() method should check the boolean value isHumanForm and if the answer is true, return "I am a human.". If the value is false, return "I cannot speak in wolf form.".
  • The sound() method should check the boolean value isHumanForm and if the answer is true, return "No sound in human form.". If the value is false, return "Howl!".
  • Click the "Run Tests" button to test your solution!
  • Все було зрозуміло?

    Секція 3. Розділ 2
    course content

    Зміст курсу

    Java OOP

    Challenge: InterfaceChallenge: Interface

    Task

    For you, two interfaces have been created: Human and Animal, as well as one class – Werewolf. Your task is to inherit both interfaces in the Werewolf class and then implement their methods. In the Werewolf class, the comments above indicate how you should override these methods. A werewolf is both a human and an animal, so it has a method called transform(). You should also use the boolean value isHumanForm in the methods as instructed. If the task seems difficult, feel free to use the Hint and Solution buttons to analyze the solution!

    Link to the task: GitHub
    Warning
    Do not modify the transform() method and do not edit the fields.
  • You have interfaces and a class. Before you start working, familiarize yourself with these interfaces and the class.
  • In the Werewolf class, you should implement two interfaces – Human and Animal. Do this using the syntax implements Human, Animal.
  • Override the methods using the @Override annotation from both interfaces.
  • The speak() method should check the boolean value isHumanForm and if the answer is true, return "I am a human.". If the value is false, return "I cannot speak in wolf form.".
  • The sound() method should check the boolean value isHumanForm and if the answer is true, return "No sound in human form.". If the value is false, return "Howl!".
  • Click the "Run Tests" button to test your solution!
  • Все було зрозуміло?

    Секція 3. Розділ 2
    some-alt