• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Soda Machine GUI

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i posted my gui twice
here's the server
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic