Desafio: 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!
transform()
method and do not edit the fields.
Werewolf
class, you should implement two interfaces –
Human
and Animal
. Do this using the syntax
implements Human
, Animal
;
@Override
annotation from both
interfaces;
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.";
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!";
Tudo estava claro?
Conteúdo do Curso
Java OOP
Java OOP
Desafio: 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!
transform()
method and do not edit the fields.
Werewolf
class, you should implement two interfaces –
Human
and Animal
. Do this using the syntax
implements Human
, Animal
;
@Override
annotation from both
interfaces;
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.";
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!";
Tudo estava claro?