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

Desafio: InterfaceDesafio: Interface

Tarefa

Para você, foram criadas duas interfaces: Humano e Animal, bem como uma classe – Lobisomem. Sua tarefa é herdar ambas as interfaces na classe Lobisomem e depois implementar seus métodos. Na classe Lobisomem, os comentários acima indicam como você deve sobrescrever esses métodos. Um lobisomem é tanto humano quanto animal, portanto possui um método chamado transform(). Você também deve usar o valor booleano isHumanForm nos métodos conforme instruído. Se a tarefa parecer difícil, fique à vontade para usar os botões Dica e Solução para analisar a solução!

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!
  • Tudo estava claro?

    Seção 3. Capítulo 2
    course content

    Conteúdo do Curso

    Java OOP

    Desafio: InterfaceDesafio: Interface

    Tarefa

    Para você, foram criadas duas interfaces: Humano e Animal, bem como uma classe – Lobisomem. Sua tarefa é herdar ambas as interfaces na classe Lobisomem e depois implementar seus métodos. Na classe Lobisomem, os comentários acima indicam como você deve sobrescrever esses métodos. Um lobisomem é tanto humano quanto animal, portanto possui um método chamado transform(). Você também deve usar o valor booleano isHumanForm nos métodos conforme instruído. Se a tarefa parecer difícil, fique à vontade para usar os botões Dica e Solução para analisar a solução!

    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!
  • Tudo estava claro?

    Seção 3. Capítulo 2
    some-alt