![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2005
Posts: 8
Rep Power: 0
![]() |
help w/ vending machine - make sure coin inserted first?
hey,
ummm im having trouble programming a vendin machine bcoz even if you don't insert a coin, but still press the button, a product will come out does anyone noe how to make sure that the coin HAS to be inserted first? thanks ![]() |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 218
Rep Power: 4
![]() |
So what language is this vending machine written then, C, C++, VB, Java ect..., LOL
|
|
|
|
|
|
#3 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
well, when a coin is inserted, you raise a flag, let's say coin_inserted.. and the button only works when the flag is raised. Not that difficult.
Welcome to the forums, btw ![]() |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Oct 2005
Posts: 8
Rep Power: 0
![]() |
hey,
i'm using a program called Microworlds - uses LOGO language... i think.... anywaiz, so how do i use flag? i really don't get it... |
|
|
|
|
|
#5 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
do you actually know the language
by flag i mean just a variable.. when a coin is inserted, the variable will contain 1, otherwise zero. |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Oct 2005
Posts: 8
Rep Power: 0
![]() |
ummmm so how would i actually type in the procedures
that if the variable is 1, then the product can be selected and if its 0 then ask the user to insert a coin? |
|
|
|
|
|
#7 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
exactly
![]() |
|
|
|
|
|
#8 |
|
Newbie
Join Date: Oct 2005
Posts: 8
Rep Power: 0
![]() |
kul!
thanks |
|
|
|
|
|
#9 | |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Quote:
![]() |
|
|
|
|
|
|
#10 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
If the flag doesn't work for you, try tipping it over to the side and shaking it.
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|