• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Java Chapter 8, page 207 example  RSS feed

 
Wilder Francisco
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

The topic of polymorphism has been a bit challenging, and although I just finished the chapter, exercises and all, I'm still a bit confused about the "AnimalTestDrive" example shown on page 207. Is that supposed to be a complete code? I tried to compile it unsuccessfully. Thanks in advance!


-----------------------------------------------------------------------------------------

 
Steve Fahlbusch
Bartender
Posts: 612
7
Mac OS X Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,

You are correct. The code you posted will not compile because you are missing at least 3 classes: Animal, Dog and Cat.

hope this helps.

-steve
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch.

I've added code tags to your post so the code is easier to read, unfortunately you have no indentation in your code so it's still not easy to read. May I suggest you always use a consistent form of indentation (using spaces not tabs) as it makes code so much easier to read. I've add some indentation to the first class for you so you can see how much better it looks.

 
Wilder Francisco
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both for the help, that cleared things up.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!