Consecutive numbers in java?
806836Oct 20 2010 — edited Oct 25 2010I am creating a slot machine class with 3 rotating disks and every disk contains the integers 0 - 9. The user will input 3 numbers of their choosing and the amount they are wagering. I am only to use if statements, i cant use arrays or random number generators or anything like that. I am having difficulty figuring out how i would tell my program to check the numbers the user inputs to make sure they are consecutive numbers in ANY order. Any number meaning it could be 1 2 3, 1 3 2, 2 1 3, 2 3 1, 3 2 1, 3 1 2.
so far i've got this for my slot machine class:
public class SlotMachine
{
private int DiskOne;
private int DiskTwo;
private int DiskThree;
private int AmountWagered;
public SlotMachine(int diskOne,int diskTwo,int diskThree,int amountWagered)
{
this.DiskOne = diskOne;
this.DiskTwo = diskTwo;
this.DiskThree = diskThree;
this.AmountWagered = amountWagered;
}
public int getDiskOne()
{
return this.DiskOne;
}
public int getDiskTwo()
{
return this.DiskTwo;
}
public int getDiskThree()
{
return this.DiskThree;
}
public int getAmountWagered()
{
return this.AmountWagered;
}
public String amountWon()
{
if (DiskOne == DiskTwo && DiskTwo == DiskThree)
{
return "All 3 Numbers The Same" + AmountWagered * 100;
}
else if(DiskOne == DiskTwo || DiskTwo == DiskThree || DiskOne == DiskThree)
{
return "Any 2 Numbers The Same" + AmountWagered * 4;
}
else if() // This is where i need some help =/ anyone?
{
return "3 Consecutive Numbers In Any Order" + AmountWagered * 20;
}
else
{
return "You Lose";
}
}
}