I have following problem. Theres is small shop which maintains the details of its customer who bought product p1 and p2. The total quantity of both the products is added and the customer details are displayed in the sorted order displaying customer who bought highest quantity on top.Also if the particular customer bought the quantity lower then some threshold, shop owner can take decison to remove it frm the current list. Now for this i have written one class which takes customer details like his name,address,p1 quantity,p2 quantity and then displays it. The other class just maintains the list of all the customer and adds or deletes them from the list.But I am not sure how to code this class as I also want to display the customer in some order. Can anybody help me in this regard?
However if you are doing this for real use, or if it's for an assignment that doesn't say anything about what kind of list you should use, then you should definitely not spend any time writing low-level code to work with lists. Instead, choose a standard List from the standard Java API -- it doesn't really matter which one you choose since your data is small, so ArrayList is as good as any other choice.
Then you can have a class that adds and deletes customers that's very simple, basically one line of code per method. To sort a list, there are also standard methods like Collections.sort(list). Here is a tutorial about lists and other collections.
Joined: Jan 24, 2006
yeah, well if you ever come across any other language, oh, such as
you dont have these little shortcuts like java does, and it's good to
know how to implent through other data structures, and see how they
actually work, dont be lazy...
ofcourse, that is, the prof tells you to be lazy...