I'm trying to write a vending machine program so far I've been able to do everything except add drinks.
I'm trying to write addDrink() method, but have not been able to.Code:public class VM{ public VM(int price) { Cost= Price; String vend [][] = new String [2][2]; drinks= new ArrayList(); } }
I'm trying to use something like drink.add(new vend(Drink_variable)), but haven't been able to. I've been reading many books but all the examples there write something else. e.g.drink.add(new vend(price p)).
Its driving me mad. I have no where to turn to. Reading books are not helping. I have no one I can ask help for. People just don't care. Probably this post that I'm writing right now will be of no use, since I won't get any useful feedback. It's easy to say write a for loop, declare an object, write a class for this or that. But I haven't been able to implement this. If I could see at least a similar example may I can learn something.
I don't know how I can add an item to an array. So everytime I call the addDrink method the list of Drinks in the array should increase. So when I display them I can see a list of the drinks I've added. And also, I should be able to determine its price and slot(eg A1) when adding.
If someone can write an example of just the add method to a vending machine that will be very helpful.
I can send you the full code that I have done so far if you want.
I would appreciate any feedback.
Regards,
John


Reply With Quote


Bookmarks