Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Erronous Output

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hello.
So I have two classes. One super class and the other a sub-class. When I run a test on it i have a method for the superclass to put out some info and a method for the sub-class to print some stuff out... however when I run the test only the stuff from the super class prints... any ideas as to what might be going on?

Super Class:


Sub-Class


Driver:
 
Marshal
Posts: 76825
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Just in case you put a real address in that code, I have changed it. Probably a security hazard to post a real address on a forum like this.

Two errors in the way you have organised your inheritance.
  • A PetDogDriver class is not a Dog.
  • Your PetDog class does not set up breed or age in the Dog class.
  • Your Dog class requires details; unless you really want a dog weight 0, you should delete the no-arguments constructor. then you would have to enter the details in the PetDog constructor.

    The PetDogDriver class should lose its extends clause.
    In PetDogDriver, you create and use a superclass object; there is no sign of you going near the subclass, so you wouldn't expect anything from the subclass to appear.
     
    Campbell Ritchie
    Marshal
    Posts: 76825
    366
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Report post to moderator
    Since there is more discussion of this question here, I shall close this thread.
     
    He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
      Bookmark Topic Watch Topic
    • New Topic