I need help creating constructors and returning boolean and strings

JohnDoe9292

I need help fixing my code with the basic concepts listed above. To save from clutter, I took a screen shot of the directions here: https://imgur.com/SdiotUi

However, when I run my code it isn't working. I know there are a lot of errors but I'm having trouble fixing them even though I've spent the past few hours googling the correct way to do this.

When I create the first constructors I am not sure if I am assigning the name and legs correctly, I am having trouble returning "true", I get an error calling the parent class taking one argument, and I don't think I am overriding the abstract class correctly.

My code:

public class Animal1 {

    private String animalName;
    public int numberOfLegs;
    public Animal1(String name){
        name = animalName;
        name = "John";
    }
    public Animal1(String name, int legs){
        name = animalName;
        legs = numberOfLegs;
        name = "Jack";
        legs = 4;
    }

    public String getName(){
        return animalName;
    }

    public int getLegs(){
        return numberOfLegs;
    }

    public void isAMammal(){ 
        return true;
    }

    public void isCarnivorous(){
        return true;
    }

    public abstract class getHello{

    }
}

public class Cat1 extends Animal1{

    public Cat1(String name){
        Animal1.name;
    }

    public abstract class getHello{   
        return "Meow";
    }
}

public class Dog1 extends Animal1{

    public Dog1(String name){
        Animal1.name;
    }

    public abstract class getHello{
        return "Woof";
    }
}
Alex Lou
public abstract class Animal1 { // If you want to have an abstract method, declare the class as abstract

    private final String animalName;
    private final int numberOfLegs; // better of using private and make it final since it's not going to change.

    public Animal1(final String name, final int legs){ //better making the input parameters final since they are not supposed to be changed
        //name = animalName; 
        //legs = numberOfLegs;//it assigned the field to an input parameter. that will take no effect on the object created.
        animalName = name;
        numberOfLegs = legs;
    }

    public String getName(){
        return animalName;
    }

    public int getLegs(){
        return numberOfLegs;
    }

    public boolean isAnimal(){ //boolean function needs a return type too!!
        return true;
    }

    public boolean isCarnivorous(){
        return true;
    }

    public abstract String getHello(); // an abstract method has same requirement as a normal method besides the abstract modifier. it will need a return type. And it ends with a semicolon

}

public class Cat1 extends Animal1{

    public Cat1(final String name){
        super(name, 4); //use super to call parent constructor
    }

    @Override
    public String getHello(){   
        return "Meow";
    }
}

public class Dog1 extends Animal1{

    public Dog1(final String name){
        super(name, 4);
    }

    @Override
    public String getHello(){
        return "Woof";
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

I need help creating a Whatsapp chatbot

From Dev

Stuck! I need some help creating this footer

From Dev

I Need Help Creating An Image On A Canvas With Tkinter

From Dev

I need help creating a modern NavBar

From Dev

I need help by creating a loop in Pygame

From Dev

I need your help on creating indicator functions

From Java

Need Help on isPerishable():boolean

From Dev

Need help creating a view

From Dev

Why do I need an IIF when returning a boolean in an SSRS expression?

From Dev

I need help returning the number of seconds between 2 months in UILocalNotification

From Dev

I need help creating 4 columns and underneath it a row with two columns

From Dev

I need help to solve for app script creating duplicate Google Tasks

From Dev

I need help creating an explicit inner join, for my coursework

From Dev

I need help creating a custom counter for items in my SQLite database

From Dev

I need help in creating swap after installation 14.04 LTS

From Dev

I need help creating a quiz in visual basic with labels

From Dev

I need help creating a for loop for document.querySelectorAll

From Dev

C#: I need Help in Creating valid ISBN property

From Dev

I need help creating a border around a checkbox form

From Dev

I need help creating a script to find error logs in Docker

From Dev

Need help understanding templated constructors in templated classes

From Dev

Need Help Compiling Java (Accessors, Mutators, Constructors)

From Dev

Creating constructors using "this" instead of simply returning an object

From Dev

Need Help Creating A Segmented Control

From Dev

Need help creating a valid nonce

From Dev

Need help creating buttons in pygame

From Java

Need help with creating custom HttpServletResponse

From Dev

Need help creating structure to database

From Dev

need help creating a if statement with a loop

Related Related

  1. 1

    I need help creating a Whatsapp chatbot

  2. 2

    Stuck! I need some help creating this footer

  3. 3

    I Need Help Creating An Image On A Canvas With Tkinter

  4. 4

    I need help creating a modern NavBar

  5. 5

    I need help by creating a loop in Pygame

  6. 6

    I need your help on creating indicator functions

  7. 7

    Need Help on isPerishable():boolean

  8. 8

    Need help creating a view

  9. 9

    Why do I need an IIF when returning a boolean in an SSRS expression?

  10. 10

    I need help returning the number of seconds between 2 months in UILocalNotification

  11. 11

    I need help creating 4 columns and underneath it a row with two columns

  12. 12

    I need help to solve for app script creating duplicate Google Tasks

  13. 13

    I need help creating an explicit inner join, for my coursework

  14. 14

    I need help creating a custom counter for items in my SQLite database

  15. 15

    I need help in creating swap after installation 14.04 LTS

  16. 16

    I need help creating a quiz in visual basic with labels

  17. 17

    I need help creating a for loop for document.querySelectorAll

  18. 18

    C#: I need Help in Creating valid ISBN property

  19. 19

    I need help creating a border around a checkbox form

  20. 20

    I need help creating a script to find error logs in Docker

  21. 21

    Need help understanding templated constructors in templated classes

  22. 22

    Need Help Compiling Java (Accessors, Mutators, Constructors)

  23. 23

    Creating constructors using "this" instead of simply returning an object

  24. 24

    Need Help Creating A Segmented Control

  25. 25

    Need help creating a valid nonce

  26. 26

    Need help creating buttons in pygame

  27. 27

    Need help with creating custom HttpServletResponse

  28. 28

    Need help creating structure to database

  29. 29

    need help creating a if statement with a loop

HotTag

Archive