Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Need an idea regarding my billing application.

 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I am Chaitanya, I am working on a billing application. User must be able to generate bills for n number of products at a time. Suppose a customer purchased 2 products, the application must take the 2 products and generate a bill for the 2 items. I designed a GUI which asks the user to enter the product id, quantity and discount.

Its not possible to have n number of fields (Text boxes) in the GUI. So placed a button named "add one more item". When the user clicks this button the existing product details must be saved somewhere and the fields must become empty. This way the user can enter any number of product details.

But the problem is where should I store the product details, if I choose an array, I have to fix the size of it at compile time. Or I can ask the user to enter the total number of products for which he wants to generate bill and then set the size of the array dynamically. But this is not a better option.

I can opt for java collections, but a product details contain the following--->pid, quantity, discount, gift items if any. I don't know whether collections can hold multiple values in one row like arrays.

Can anyone help me? Thank you all in advance.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create a class to hold all the details for one item, and then use a collection class (an ArrayList for example) to hold instances of that class.

For example:

 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mr. Jesper, thanks for your post. I ll try that.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mr. Jesper, it worked.
 
What's gotten into you? Could it be this tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic