Whats wrong with this code? for some reason it is evaluating each else statement..
Just for useless info this is part of my Vending machine project in Rose Real Time..
Just for useless info this is part of my Vending machine project in Rose Real Time..
Code:
if (ItemNumber == 1 && Pepsi > 0)
{
Pepsi--;
log.log ("Thank You For Purchasing a Pepsi!");
transaction.newComplete().send();
}
else
{
log.log ("Sorry, Item is currently out of stock.");
cancle.newCancle(ItemNumber).send();
}
if (ItemNumber == 2 && Fizzle > 0)
{
Fizzle--;
log.log ("Thank You For Purchasing a Fizzle!");
transaction.newComplete().send();
}
else
{
log.log ("Sorry, Item is currently out of stock.");
cancle.newCancle(ItemNumber).send();
}
if (ItemNumber == 3 && Squishy > 0)
{
Squishy--;
log.log ("Thank You For Purchasing a Squishy!");
transaction.newComplete().send();
}
else
{
log.log ("Sorry, Item is currently out of stock.");
cancle.newCancle(ItemNumber).send();
}
if (ItemNumber == 4 && Yohoo > 0)
{
Yohoo--;
log.log ("Thank You For Purchasing a Yohoo!");
transaction.newComplete().send();
}
else
{
log.log ("Sorry, Item is currently out of stock.");
cancle.newCancle(ItemNumber).send();
}