RIght now im taking this class on programming languages where they teach you about what goes into making a language. Every so often they give programming assignments on in different languages but never teach you anything about the language. Im having a lot of trouble with this Java.
this works fine but when i have to write my class Cat that extends Pet is when stuff doenst work
i get this strange error and i have no clue how to fix it... someone please help me!
Code:
public class Pet
{
protected String pet_name;
protected String owner_name;
protected String color;
protected int sex;
public static final int MALE=0, FEMALE=1, SPAYED=2, NEUTERED=3;
//make an array for hte strings for MALE, FEMALE, etc...
String[] sexarray = {"MALE", "FEMALE", "SPAYED", "NEUTERED"};
public Pet(String name, String ownerName, String c)
{
pet_name = name;
owner_name = ownerName;
color = c;
}
public String getPetName()
{
return pet_name;
}
public String getOwnerName()
{
return owner_name;
}
public String getColor()
{
return color;
}
public void setSex(int sexid)
{
sex = sexid;
}
public String getSex()
{
return sexarray[sex];
}
public String toString()
{
return (pet_name + " owned by " + owner_name + "\nColor: " + color + "\nSex: " + getSex());
}
}
this works fine but when i have to write my class Cat that extends Pet is when stuff doenst work
Code:
public class Cat extends Pet
{
private String hairLength;
//Pet temp;
public Cat(String name, String OwnerName, String c, String HairLength)
{
pet_name = name;
owner_name = OwnerName;
color = c;
//Pet temp = new Pet(name, OwnerName, c);
hairLength = HairLength;
}
public String getHairLength()
{
return hairLength;
}
public String toString()
{
return ("CAT: \n" + getPetName() + "is owned by " + getOwnerName() + "\nColor: " + getColor()
+ "\nSex: " + getSex() + "\nHair: " + getHairLength());
}
}
i get this strange error and i have no clue how to fix it... someone please help me!