Join 150,369 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,831 people online right now. Registration is fast and FREE... Join Now!
Anyone know why I cannot create this second object called VirtualPet? I keep getting an error saying "Compilation Error: Virtual Pet could not be resolved to a type"
Here's the tester file (with the error on line 14)
Remember, you can't instantiate abstract classes. Abstract means that it is to serve as a base class to inherit from, not that it is going to be used to create an object from.
So remove the word "abstract" from your virtualpet class definition. Since you are not explicitly inheriting from another class, you can also get rid of the call to "super()". While it won't be a problem to keep it in, you are just saying that you call the object's base class constructor... which is in this case Object. This is done by default anyways.
Then make sure that you have both files in the same directory and it should compile fine. See if that works for you.
Hmm... I'm getting errors from this part. The compiler keeps saying that the methods require a body instead of a semicolon even though its declared as abstract?
CODE
public abstract class VirtualPet{ String getName(); boolean isEating(); boolean isSleeping(); }