• Post Reply Bookmark Topic Watch Topic
  • New Topic

Polymorphy & inheritance  RSS feed

 
Andreas Reisser
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys,

I have some trouble with the code i�ve written accoring to "Java from head to toe".

Here s my code:

Class1:



Class2:


Class3:



Class4:



Class5:



I tested every single class by it�s own ... everything worls perfect ... BUT if i run my Starterclass ( Tierbesitzer ) i get no ouput @ the DosBox

( i�m using java 5.0 upgrade 7 & JavaEditor by Gerhard R�hner)

Anyone knows what�s wrong ?

Best regards,

cab
[ August 06, 2006: Message edited by: Andreas Reisser ]
 
Andreas Reisser
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ August 06, 2006: Message edited by: Andreas Reisser ]
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that in your main method, you are simply creating an instance of the class. Since there is no constructor defined, and the class extends Object which has a no-args constructor, a default constructor is generated for the class.

However, after you create the instance, you don't do anything with it. That is why nothing prints.
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add

neuerBesitzer.start()

to your main method and you should see output.
 
Andreas Reisser
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dooh !!

Thank you Guys Obviously I was too blind to see whats going on *G*

BB

Cab
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!