• Post Reply 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

To Phrase it another way

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would a class upon compile not see the class it is extending? This is referring to my other post earlier. My OrderWithCharge class cannot see the Order class. Am I not using the [BOLD]extends[/BOLD] correctly? I have an Order.class file in the directory......... Thanks for your time and expertise..
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A basic example:



Note:
The parent and child CAN be in seperate packages ( package is a synonym for directory ) as long as they reference each other correctly and the variables/methods within the parent have the right access privileges.
Try this example out, and post more questions back if needed as i'm not sure if this completely answers your question!
When you compile the above example you will get 2 directories, matt and notmatt. In matt you will get the child and main classes and in notmatt the parent class.
T
[ November 28, 2002: Message edited by: le taylom ]
 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am going to post all my code. Hopefully it is not too much and becomes confusing. All my classes should be in the same package. I am using a batch file to compile and run these classes. Here is the code from parent on down:



The last class just instantiate the previous and is supposed to display with the toString() method. The problem is that the child class OrderWithCharge is not compiling and is giving the error of cannot resolve symbol, which is pointing at all the references to super and to the extends Order line. Dont give me the code per se but rather what is wrong with it. This is a class project and I am supposed to code it myself but can look for help. Thanks for the help.
 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Drop the batch file to compile. Compile Order.class first, then OrderWithCharge.
See if it works. If not, then it is probably because you have classpath problem.
Check where your .class are generated and see if this directory appears in your classpath.
W.
 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you compiling in a good order?
Make a javac *.java, so you don't have to worry about the order to compile.
Hope it helps you!
 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the class we are to use a batch file to compile. Of course I did compile Order then OrderWithCharge, and then TestOrderAmt. Now it seems to be compiling fine but no output on the screen.??? Work will continue this evening on this problem any ideas about things to change in the code would be welcome. Thanks for any time that you may spend on this. I am sure I will have more questions out here on the next two parts of this project. As always I do not want the code written for me, just ideas and maybe hints. I am supposed to be learning this stuff after all...
 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK so now everything runs pretty close to the right way. In my batch file I am putting the .class files in another directory. I had those messed up. It is straightened out now. Only problem is my OrderWithCharge is not overriding the Order calcTotal() method. It keeps displaying the fee with handling charge a the same as without the handling charge.??? I will keep working on it, but if someone sees something amiss.........
 
Message for you sir! I think it is a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic