File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To Phrase it another way

 
mike hengst
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • 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..
 
le taylom
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Younes Essouabni
Ranch Hand
Posts: 479
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.........
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic