TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Fred Stilms
NA
6
0
Problem with my project Vending machine C# WPF
Dec 7 2009 12:57 PM
i cant seem to compare the result of the instered coins and the price of the drink
The Flow of the project.
1.The Report "Choose" shown on the screen on start window.
2.User chooses Drink /Coke/Water/Coffie/Beer//
The choice is made by clicking on of the drinks in Make a Choice
The drink and price displays next to the "current choice".
The Report changes from choose to Pay.
3.The user can now click on the Coin Buttons //2/1/0.50/0.20/0.10/0.05Euro//
the total of the coin insert is displays next to the inserted coin(s)
4.When there is enough money inserted the coin buttons become inactive.
and the button Buy drink becomes active
the Report changes to buy drink
5.Afther the user clicks Buy drink
The report changes to "take drink"
below report there is another report given:
-Take your "chosen drink"
-money back "the money that is more than the price of the drink"
-the total coin given back
The button Take Drink becomes visble
And all the rest of the buttons become inactive
6.After the user clicks on take drink the program starts again.
Note: Till point 4, the user can still change drink.So the If the drinks changes price and the inserted coins are blow or more than the chosen drink
The Report changes also Pay or Buy
Prices are Coke 0,50€ /Water0,60€ /Coffie 1,20 / Beer 4€
pic:
http://img338.imageshack.us/img338/5613/softdrinkvend.jpg
Code atm:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Data;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Imaging;
using
System.Windows.Navigation;
using
System.Windows.Shapes;
namespace
Vending_Machine
{
///
<summary>
///
Interaction logic for Window1.xaml
///
</summary>
public
partial
class
Window1
:
Window
{
double
result;
public
Window1()
{
InitializeComponent();
}
private
void
btnCola_Click(
object
sender,
RoutedEventArgs
e)
{
Drank
d;
d =
new
Drank
();
double
cola = d.coladrank();
lblSortDrink.Content = cola;
groupBox2.IsEnabled =
true
;
}
private
void
btnWater_Click(
object
sender,
RoutedEventArgs
e)
{
Drank
d;
d =
new
Drank
();
double
water = d.waterdrank();
lblSortDrink.Content = water;
}
private
void
btnCoffie_Click(
object
sender,
RoutedEventArgs
e)
{
Drank
d;
d =
new
Drank
();
double
koffie = d.koffiedrank();
lblSortDrink.Content = koffie;
groupBox2.IsEnabled =
true
;
}
private
void
btnBeer_Click(
object
sender,
RoutedEventArgs
e)
{
Drank
d;
d =
new
Drank
();
double
soep = d.soepdrank();
lblSortDrink.Content = soep;
groupBox2.IsEnabled =
true
;
}
private
void
button11_Click(
object
sender,
RoutedEventArgs
e)
{
groupBox1.IsEnabled =
false
;
groupBox2.IsEnabled =
false
;
}
private
void
Window_Loaded(
object
sender,
RoutedEventArgs
e)
{
groupBox2.IsEnabled =
false
;
}
private
void
btnTwo_Click(
object
sender,
RoutedEventArgs
e)
{
Geld
g;
g =
new
Geld
();
double
tweeEuro = g.tweeEurogeld();
if
(
Convert
.ToDouble(lblSortDrink.Content) > (
Convert
.ToDouble((lblInsertedCoins.Content))))
{
result += tweeEuro;
lblInsertedCoins.Content = result;
}
}
private
void
btnOne_Click(
object
sender,
RoutedEventArgs
e)
{
Geld
d;
d =
new
Geld
();
double
eenEuro = d.eenEurogeld();
if
(
Convert
.ToDouble(lblSortDrink.Content) > (
Convert
.ToDouble((lblInsertedCoins.Content))))
{
result += eenEuro;
lblInsertedCoins.Content = result;
}
}
private
void
btnFifty_Click(
object
sender,
RoutedEventArgs
e)
{
Geld
g;
g =
new
Geld
();
double
vijtigCent = g.vijtigCentgeld();
if
(
Convert
.ToDouble(lblSortDrink.Content) > (
Convert
.ToDouble((lblInsertedCoins.Content))))
{
result += vijtigCent;
lblInsertedCoins.Content = result;
}
}
private
void
btnTwinty_Click(
object
sender,
RoutedEventArgs
e)
{
Geld
g;
g =
new
Geld
();
double
twintigCent = g.twintigCentgeld();
if
(
Convert
.ToDouble(lblSortDrink.Content) > (
Convert
.ToDouble((lblInsertedCoins.Content))))
{
result += twintigCent;
lblInsertedCoins.Content = result;
}
}
private
void
btnTen_Click(
object
sender,
RoutedEventArgs
e)
{
Geld
g;
g =
new
Geld
();
double
tienCent = g.tienCentgeld();
if
(
Convert
.ToDouble(lblSortDrink.Content) > (
Convert
.ToDouble((lblInsertedCoins.Content))))
{
result += tienCent;
lblInsertedCoins.Content = result;
}
}
private
void
BtnFive_Click(
object
sender,
RoutedEventArgs
e)
{
Geld
g;
g =
new
Geld
();
double
vijfCent = g.vijfCentgeld();
if
(
Convert
.ToDouble(lblSortDrink.Content) > (
Convert
.ToDouble((lblInsertedCoins.Content))))
{
result += vijfCent;
lblInsertedCoins.Content = result;
}
}
private
void
btnCancel_Click(
object
sender,
RoutedEventArgs
e)
{
groupBox2.IsEnabled =
false
;
btnBuy.IsEnabled =
false
;
}
private
void
btnBuy_Click(
object
sender,
RoutedEventArgs
e)
{
/*double priceDrink;
double insertedCoin;
double moneyback;
moneyback = priceDrink - insertedCoin;*/
}
}
}
and i made two classes
(Drinks)
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
Vending_Machine
{
partial
class
Drank
{
public
int
cola;
public
int
water;
public
int
koffie;
public
int
soep;
public
double
coladrank()
{
double
cola = 1.00;
return
cola;
}
public
double
waterdrank()
{
double
water = 1.20;
return
water;
}
public
double
koffiedrank()
{
double
koffie = 2.50;
return
koffie;
}
public
double
soepdrank()
{
double
soep = 4.00;
return
soep;
}
}
}
(money)
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
Vending_Machine
{
partial
class
Geld
{
public
int
tweeEuro;
public
int
eenEuro;
public
int
vijtigCent;
public
int
twintigCent;
public
int
tienCent;
public
int
vijfCent;
public
double
tweeEurogeld()
{
double
tweeEuro = 2.00;
return
tweeEuro;
}
public
double
eenEurogeld()
{
double
eenEuro = 1.00;
return
eenEuro;
}
public
double
vijtigCentgeld()
{
double
vijtigCent = 0.50;
return
vijtigCent;
}
public
double
twintigCentgeld()
{
double
twintigCent = 0.20;
return
twintigCent;
}
public
double
tienCentgeld()
{
double
tienCent = 0.10;
return
tienCent;
}
public
double
vijfCentgeld()
{
double
vijfCent = 0.05;
return
vijfCent;
}
}
}
any tips to resolving my noobie code^^
Reply
Answers (
0
)
Using GzipStream to zip up more then one file
Windows Mobile 5.0 application and printing (or, PDF generation)