A
AMT2K5
Hello,
I have a simple data script that looks like this:
Box of
Hammer(s)
#
6 Pack of
Washer(s)
#
Which is stored in a StringBuffer
I have the code
InventoryItem[] InvItems = new InventoryItem[10];
for(int i = 0; i < 10; i++) {
InvItems = new InventoryItem();
InvItems.inventoryId = i+1; // ?
InvItems.quantityInStock = 2.5 *
InvItems.inventoryId;
InvItems.update(a);
}
Where (a) is the passed into the method as a StringBuffer consisting of
that data script read at an earlier time.
I want to update each object's attributes consisting of Product and
Unit/Package, by using the update function (public int
update(StringBuffer sb)) .
How would I go about doing that?
So InvItems[0] has a product of 'Hammer(s)' and a unit/package of 'Box
Of',
in the for loop when InvItems[1] comes along, it has a product of
'Washer(s)' and a unit/package of '6 Pack-of'
Thanks in advance, any help appreciated.
PS: I figure it will look something like this to start
public int update(StringBuffer sb){
String temp = new String();
StringTokenizer tk = new StringTokenizer(sb.toString(),"#");
while (tk.hasMoreTokens()) {
System.out.println(tk.nextToken());
}
return 0;
}
My data script looks like this
Box of 100
Bolt(s)
#
Motherload of
Widget(s)
#
Box of 25
Grommet(s)
#
Box of 50
Hammer(s)
#
24-Pack of
Washer(s)
#
Box of
Gizmo(s)
#
One
Blade(s)
#
6-Pack of
O-Ring(s)
#
Motherload of
Thingy(ies)
#
Box of
Nut(s)
#
Each pair between the sharps are the two attributes for the current
object this.
I have a simple data script that looks like this:
Box of
Hammer(s)
#
6 Pack of
Washer(s)
#
Which is stored in a StringBuffer
I have the code
InventoryItem[] InvItems = new InventoryItem[10];
for(int i = 0; i < 10; i++) {
InvItems = new InventoryItem();
InvItems.inventoryId = i+1; // ?
InvItems.quantityInStock = 2.5 *
InvItems.inventoryId;
InvItems.update(a);
}
Where (a) is the passed into the method as a StringBuffer consisting of
that data script read at an earlier time.
I want to update each object's attributes consisting of Product and
Unit/Package, by using the update function (public int
update(StringBuffer sb)) .
How would I go about doing that?
So InvItems[0] has a product of 'Hammer(s)' and a unit/package of 'Box
Of',
in the for loop when InvItems[1] comes along, it has a product of
'Washer(s)' and a unit/package of '6 Pack-of'
Thanks in advance, any help appreciated.
PS: I figure it will look something like this to start
public int update(StringBuffer sb){
String temp = new String();
StringTokenizer tk = new StringTokenizer(sb.toString(),"#");
while (tk.hasMoreTokens()) {
System.out.println(tk.nextToken());
}
return 0;
}
My data script looks like this
Box of 100
Bolt(s)
#
Motherload of
Widget(s)
#
Box of 25
Grommet(s)
#
Box of 50
Hammer(s)
#
24-Pack of
Washer(s)
#
Box of
Gizmo(s)
#
One
Blade(s)
#
6-Pack of
O-Ring(s)
#
Motherload of
Thingy(ies)
#
Box of
Nut(s)
#
Each pair between the sharps are the two attributes for the current
object this.