This is the current code giving the issue
G1.setPet(C2);
G2.setPet(C1);
System.out.println(G1.getPet().getGname);
The output I'm getting is " The Gorilla's name...
Type: Posts; User: Vessel06
This is the current code giving the issue
G1.setPet(C2);
G2.setPet(C1);
System.out.println(G1.getPet().getGname);
The output I'm getting is " The Gorilla's name...
Ok...this is the prof's example/instruction "In your harness, check that your new accessor and mutator work. For instance, if you have a Gorilla koko and a Cat fluffy, you should be able to say
...
YOU SIR ROCK!!!! I passed in the right identifier
public void setPet(Cat c) {
this.pet = c;
}
Now the problem is to make sure it all runs in the harness when I give the...
But when I simply put
public void setPet(c) {
this.pet = c; //this is the error
}
Java gives another error stating that an identifier still needs to be made...unsure what I...
Is this what you meant?
public void setPet(String Cat) {
this.pet = Cat;
}
Because if so, Java gives and error stating "incompatible types required: Cat found: String"
---...
No I didn't change any of the variables
Ok that makes more sense but does it make a difference that the variable is like that because it's supposed to call on the cat class that is already written and correct since my prof checked it...
the setPet method in particular. maybe i'm misunderstanding the way the mutator works but I figured that
public void setPet (String c) {
this.pet = c;
should work....but for some reason...
ok same assignment(discussed in the question abt mutators) new problem, in my class gorilla, we have to give it a pet cat with the accessors and mutators for the pet cat in the gorilla class... this...