• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

file i/o

 
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 I have worked this to being pretty colse to what I need. The only problem left(Ihope) is that not everything I want to be outputted to the orderout file is showing up. The data must be being passed to the super class because the output I am getting hs been calculated, which is done in the super class(Order). I am only getting the extended price with the handling charge added on. What am I not doing that is causing this???HELP. Here is the code for the two classes in question. I think it may have to do with the toString() itself and will keep working on it, bu tI would appreciate a second(or more) set of eyes to look at it...Thanks
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually when you're continuing a previous topic, it's best to put your new post as an "Add" to the existing topic, rather than as a separate topic. The old topic will appear "new" once it has a new post in it (i.e. the date/time appearing next to the topic will be the date/time of the most recent post, and the topic will appear at the top of the topic list until something even newer is posted). By adding to the previous post, you make it easier for everyone to have the complete context of your problem. And you prevent anyone from wasting their time responding to the original post if you've already solved some of the problems (as in this case) - they can see the most recent version of your code in the same thread, without having to search elsewhere. Which is usually easier for all of us. Anyway...
I think your primary problem right now is in the OrderWithCharge toString() method. You call super.toString() - but you don't do anything with the String that this method returns. I think you want to append this to your StringBuffer somewhere, e.g.:

Some other observations...
In class ProcessOrders:
The various private static arrays aren't used for anything, are they? If you do need to save the order info for use later, I'd use either a single OrderWithCharge[] array, or a Collection such as ArrayList containing OrderWithCharge elements.
Initializing all your array lengths to 4 seems questionable - what if this number needs to change later? I'd replace each 4 with a variable (probably static and final), such as MAX_RECORD_COUNT. Then it's easy to change later if you need to. OF course, if you use some sort of Collection you probably won't need to specify a maximum size anyway - the Collection will simply grow as you add elements to it.
Inside the processOrder() method, there seems to be a lot of redundant stuff. The OrderWithCharge constructor appears to set name,id,qt,prc,item - there's no need to set these again immediately after using owc.setCustName(name) etc.
In class OrderWithCharge:
Again, the static arrays are pretty suspicious looking - why are they needed? It seems that all the data you need are already declared as instance (non-static) fields of either Order or OrderWithCharge - just use these fields.
It looks like your computeCharges() method is doing a lot more work than it needs to - for each individual order, it's rereading the quantities and recalculating the charges for all the orders. Why? It seems that quantities have already been read from the orderin.txt file - are the quantities in charges.dat different? If they are, then you shoudl probably use different names to distinguish the two types of quantitites. In any event, if you need to read the file charges.dat in addition to orderin.txt, just do it once, in a static method somewhere - and put the data you've read into the appropriate fields in your array/Collection or OrderWithCharge objects.
Hope that helps. Good luck...
[ December 15, 2002: Message edited by: Jim Yingst ]
 
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic