Hello! I am very new to Java, and this error is throwing me off big time. I have written a method inside a class, but I’m having a super tough time getting the code to run without errors.
Currently an error on line 15 “illegal start of an expression”
Any help pointing me in the right direction is GREATLY appriciated
public class Pet {
// Instance fields
private String petType;
private String petName;
private int petAge;
private int dogSpaces;
private int catSpaces;
private int daysStay;
private double amountDue;
// Constructor with two parameters
public Pet(String type, String name, int age) {
// Initialize local variables for pet type (cat or dog)
String cat = "Cat";
String dog = "Dog";
// Conditional statement to determine type of pet checking in
if (petType == "Cat") {
petType = cat;
return petType;
} else {
petType = dog;
return petType;
}
petName = name;
petAge = age;
}
// Mutator methods
public void setPetType(String) {
// FIXME - user input for pet petType
petType = type;
}
public class Cat {
private String petName;
private int petAge;
private int catSpaceNumber;
public Cat() {
name = "No name";
petAge = 0;
catSpaceNumber = 0;
}
public void getCatSpaceNumber(int spaceNumber) {
catSpaceNumber = spaceNumber;
return catSpaceNumber;
}
}
}