• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some thing better than an array

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello world,
I am hoping to write a stock controlling program. In that, I have a function to print a bill. Which the user can add items to the bill with the quantyties...
I am doing this in 'SWING' and I am using the JTable class to show the bill. Means that it has columns such as 'items code', qty, price per uni and subtotal etc..
In my program I have the options of deleting an entry in the bill, undo an entry redo an entry, edit an entry(say you entere 10 pieces for 1 piece accidentally and you want to crrect it.) So far what I did was having the entries in an 2D array and messing with it. It is really hard and results in unexpected erros. Please do advice me a good solution to corp these needs.
Thanks.
More descriptive answeres are very much welcome.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally, what you want to do here is create a "BillItem" class that looks like:

Then, you put objects of this class into a List (usually an ArrayList) and display that list.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You very much for the answer.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic