473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Smart people needed. =O!

Possessed0ne
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 =)

Expand|Select|Wrap|Line Numbers
  1. public class Energydrinkmachine
  2.   {
  3.  
  4.  
  5.   private int price;
  6.  
  7.   private int balance;
  8.  
  9.   private int total
  10.  
  11.  
  12.  
  13.   public Energydrinkmachine(int drinkcost)
  14.   {  
  15.       price = 5;
  16.       balance = 0;
  17.       total = 0;
  18.  
  19.  
  20.   }
  21.   public int getPrice()
  22.   {
  23.         return price;
  24.  
  25.   }
  26.  
  27.  
  28.   public int getBalance()
  29.   {
  30.       return balance;
  31.  
  32.   }
  33.  
  34.   public void insertMoney(int amount)
  35.   {
  36.       balance = balance + amount;
  37.   }
  38.  
  39.   public void printDrink()
  40.   {
  41.  
  42.     System.out.println("heres your soda")
  43.     System.out.println();
  44.  
  45.  
  46.   }
  47.  
  48. }
Mar 17 '08 #1
1 1000
r035198x
13,262 8TB
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.
Mar 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

124
by: 43 | last post by:
how come m$Office isn't written in .net? how come Open Office isn't written in j2ee? how come dbms systems aren't written in either? how come browsers aren't written in either? how come...
9
by: christopher diggins | last post by:
I would like to survey how widespread the usage of smart pointers in C++ code is today. Any anecdotal experience about the frequency of usage of smart pointer for dynamic allocation in your own...
27
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined...
6
by: Shankar | last post by:
Hello, We have a smart pointer class which provides the dereference operator -> to access the underlying object pointer. Now, we have a new requirement where a different type of object (e.g from...
59
by: MotoK | last post by:
Hi Experts, I've just joined this group and want to know something: Is there something similar to smart pointers in C or something to prevent memory leakages in C programs. Regards MotoK
92
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers,...
21
by: Raj | last post by:
Hi, We just executed a project with Python using TG. The feedback was to use more python like programming rather than C style code executed in Python. The feedback is from a Python purist and...
33
by: Ney André de Mello Zunino | last post by:
Hello. I have written a simple reference-counting smart pointer class template called RefCountPtr<T>. It works in conjunction with another class, ReferenceCountable, which is responsible for the...
54
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining...
50
by: Juha Nieminen | last post by:
I asked a long time ago in this group how to make a smart pointer which works with incomplete types. I got this answer (only relevant parts included): ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.