/help ping

Hi…. I’ve just started learning Java this week and I have a submission due for uni tomorrow but I am struggling… lol. I cannot figure out where I’m going wrong, I’ve read over my notes and text books and watched tutorials but I don’t know where I’ve went wrong, I’m just looking for some guidance on how to fix the code. any help is appreciated.
No description
No description
No description
No description
No description
3 Replies
JavaBot
JavaBot2mo ago
This post has been reserved for your question.
Hey @rachel_mccullough! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
lisan
lisan2mo ago
public abstract class Pet {

private String name;
private int age;

public Pet(String name, int age) {
this.name = name;
this.age = age;
}

public abstract String speak();

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

}


public class Cat extends Pet {

private CatBreed breed;

public Cat(String name, int age, CatBreed breed) {
super(name, age);
this.breed = breed;
}

@Override
public String speak() {
return "Meow! I am " + getName() + ", a " + getAge() + " year old " + breed;
}

public CatBreed getBreed() {
return breed;
}

public void setBreed(CatBreed breed) {
this.breed = breed;
}

}

public enum CatBreed {

PERSIAN,
TABBY

}

public class Dog extends Pet {

private DogBreed breed;

public Dog(String name, int age, DogBreed breed) {
super(name, age);
this.breed = breed;
}

@Override
public String speak() {
return "Woof! I am " + getName() + ", a " + getAge() + " year old " + breed;
}

public DogBreed getBreed() {
return breed;
}

public void setBreed(DogBreed breed) {
this.breed = breed;
}

}

public enum DogBreed {

SPANIEL,
TERRIER

}

public class Main {
public static void main(String[] args) {
Pet cat = new Cat("Pixel", 4, CatBreed.TABBY);
Pet dog = new Dog("Rex", 9, DogBreed.TERRIER);

System.out.println(cat.speak());
System.out.println(dog.speak());
}
}
public abstract class Pet {

private String name;
private int age;

public Pet(String name, int age) {
this.name = name;
this.age = age;
}

public abstract String speak();

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

}


public class Cat extends Pet {

private CatBreed breed;

public Cat(String name, int age, CatBreed breed) {
super(name, age);
this.breed = breed;
}

@Override
public String speak() {
return "Meow! I am " + getName() + ", a " + getAge() + " year old " + breed;
}

public CatBreed getBreed() {
return breed;
}

public void setBreed(CatBreed breed) {
this.breed = breed;
}

}

public enum CatBreed {

PERSIAN,
TABBY

}

public class Dog extends Pet {

private DogBreed breed;

public Dog(String name, int age, DogBreed breed) {
super(name, age);
this.breed = breed;
}

@Override
public String speak() {
return "Woof! I am " + getName() + ", a " + getAge() + " year old " + breed;
}

public DogBreed getBreed() {
return breed;
}

public void setBreed(DogBreed breed) {
this.breed = breed;
}

}

public enum DogBreed {

SPANIEL,
TERRIER

}

public class Main {
public static void main(String[] args) {
Pet cat = new Cat("Pixel", 4, CatBreed.TABBY);
Pet dog = new Dog("Rex", 9, DogBreed.TERRIER);

System.out.println(cat.speak());
System.out.println(dog.speak());
}
}
you have problem with bracelets
{}
{}
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server