Smart people needed. =O!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Possessed0ne
    New Member
    • Mar 2008
    • 1

    Smart people needed. =O!

    hi peoples, i started object oriented programing about 2 weeks ago and i pretty much get the concept that everything is an object which is under class which uses methods in order to do "stuff".

    im trying to make a virtual vending machine, that will produce 3 options and you will pick by saying a. b. or c. and the money thing will work by just typing in "100" or whatever price it is, i need help with the interface =( i know html for the thing but im not sure how i'd do it in java to make a "submit" button to check if the money value is equal to the price....this is what i have so far and its...a mess... =/ a little help would be greatly appreciated =)

    [CODE=java]public class Energydrinkmach ine
    {


    private int price;

    private int balance;

    private int total



    public Energydrinkmach ine(int drinkcost)
    {
    price = 5;
    balance = 0;
    total = 0;


    }
    public int getPrice()
    {
    return price;

    }


    public int getBalance()
    {
    return balance;

    }

    public void insertMoney(int amount)
    {
    balance = balance + amount;
    }

    public void printDrink()
    {

    System.out.prin tln("heres your soda")
    System.out.prin tln();


    }

    }[/CODE]
    Last edited by Ganon11; Mar 17 '08, 06:14 PM. Reason: Please use the [CODE] tags provided.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Your post violates the posting guidelines on these points :
    1.)You did not use an appropriate thread title.
    2.) You did not use code tags for your code.

    I don't see any reference to a button in your code.
    If you want to use a button then have a look at the JButton class. You'd also need to know how to use JFrames and ActionListeners .
    If this is not required for this assignment then you can use JOptionPane's showInputDialog method to get a Dialog which comes all dressed with the event handling stuff already.

    Comment

    Working...