• Post Reply Bookmark Topic Watch Topic
  • New Topic

Soda Machine GUI  RSS feed

 
Jon Jesuraj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been struggling with this for almost a week in Java class This is the description of it
A soda machine contains Pepsi, Root Beer, Gatorade, and Poland Spring Water.
The machine, when it is full contains 25 of each. The cost of Pepsi and Root Beer is $1.50, Gatorade is $2.25 and Poland Spring Water is $1.25. The machine will dispense the drink and keep track of how much money is in the machine when the user inputs the password. Additionally the user should be able to change the password.

This is my server class

This is my cleint


Now this all works fine but trying to do the GUI
here is what I have so far


please help me
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

So what does the code do so far, what is still missing, and where are you stuck implementing the missing pieces?
 
Jon Jesuraj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the GUI so far

and this is my server


The problem right now is that I'm allowed to buy unlimited drink and the amount of money in the machine always comes out to $0. I think my getMeDrink(int drinktype) method isnt working correctly. Can anyone help me fix it??
 
Jon Jesuraj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i posted my gui twice
here's the server
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Can anyone help me fix it??

possibly only those with the BreezySwing classes.

having a quick read of your code, I'd be inclined
to structure your GUI a bit like this

1) a Drink class, with name and price variables
2) a DrinkPanel class, with Drink and quantity variables,
a JButton to display the drink name/price, possibly a
JRadioButton for quantity status.
in the button's actionListener
quantity--;
if(quantity == 0)
{
JRadioButton.setSelected(true)
JRadioButton.setText(*Empty*)
JButton.setEnabled(false)
}
the DrinkPanel class would also have a method addQuantity(int n)
which will increase the quantity by 'n', and reverse the above actions

now, in your SodaMachine gui, you create a mainpanel (gridLayout) and add
new DrinkPanel(new Drink(name,price),quantity)
as many times as you have drinks.
then you add all your other stuff, maintenance, password, coins etc
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!