How do I write a method called shop?
<p>Very much stuck at this after coding the attributes of myItemList and also the CartItem. Hope anyone can help. Wrote a brief description for the method below.</p>

<pre><code>public CartItem[] Shop (int numOfItems) {
    }
</code></pre>

<p>Shopper 'shops' using this method. It takes the numberOfItems to be shopped and it will return an array of CartItems. I'll need a for lopp that iterates numberOfItems times as shopper buys these many items, one in each iteration of the loop. So each iteration will create a CartItem object and store it in the current position of the array.</p>

<p>Then will have to generate a random number between 0 => numOfItems -1
The item with the random number is chose by the shopper. The shopper has to also check whether there are only less than 50 peieces of that item in the array myItemList. If so, the item will be restocked and the quantity will be made 100 and she should not buy the item in the for loop.</p>

<p>The item with that index (the random number that you have generated) is chosen by the shopper. The shopper should first check whether there are only less than 50 pieces of that item in myItemList. If so, she has to restock that item (make the quantity 100) and she should not buy that item in the current iteration of the for loop. Now you have to remember whether the shopper restocks an item in some way (you can work out a very simple logic) in the current CartItem object.</p>

<p>The shopper buys 50 pieces of the item if there are >=50 pieces of that item available. You have to store this item the CartItem object that you have created and also store it in the basket array.</p>

<p>You have to return the basket array when the for loop is completely executed.</p>
