Re: Collection Class object enhancements



Yes, you are correct. However, in this case each line item is assigned an
employeeId who receives credit (commission) for the item. So it is possible
that two different employees receive credit for one or more of the same
item. So I am still stuck trying to store the quantity of each item.

WB


"Larry Serflaten" <serflaten@xxxxxxxxxxxxxx> wrote in message
news:OMonPNYiGHA.1260@xxxxxxxxxxxxxxxxxxxxxxx

"wb" <none> wrote
I have a collection class that I created to store LineItem objects of a
shopping cart.
<...>
Inside my collection class I want to have something that tabulates the
total
of each item.
<...>
I also created a countNumberId function that takes the item Id (NC001)
and
will return the sum of quantity.
<...>
This works ok, but I think there might be a better way to accomplish
this.
Suggestions?

It appears the collection is the shopping cart for one user. Since you
know
you will want a tally of the individual items ordered, why not keep a list
of
distinct items, instead of the line item scenareo. If they scan the same
item
twice, it increments that item, rather than creating a new line item.
etc...

When you return the Count, it should be the sum total of all items
ordered.
There would be no need for the countNumberID function because every
different item would have its 'quantity ordered' already stored, easily
available.

LFS





.


Loading