0

When i try to complile it says

SlotMachineReel.java:175: missing return statement

I think its because all my returns are in "if" statements and it needs a default return.

line 128

&

line 175

Thanks in advance for any help

```
/**
* Constructs a new reel with its current face randomly set to
* one of the 6 symbols on this reel.
*/
public class SlotMachineReel{
private String face;
private int slot;
/**
* Cherry = 0
* Watermelon = 1
* Lemon = 2
* Bell = 3
* Number 7 = 4
* Coin = 5
*/
public SlotMachineReel() {
this.face = spin();
}
/**
* Spins this reel. This randomly sets this reel's face to
* one of its 6 symbols: "CHERRY", "MELON", "LEMON", "COIN",
* "BELL", or "SEVEN".
*
* Returns the new symbol showing on this reel after the spin.
*/
public String spin() {
this.slot = (int) (Math.random()*6);
switch(this.slot){
case 0:
return face = "Cherry";
case 1:
return face = "Watermelon";
case 2:
return face = "Lemon";
case 3:
return face = "Bell";
case 4:
return face = "7";
case 5:
return face = "Coin";
default:
return face = "Error";
}
}
/**
* Returns the current face of this reel. This is the same
* value as returned by the last call to spin().
*/
public String getFace() {
return face;
}
}
class SlotMachine {
private boolean lFruit;
boolean cFruit;
boolean rFruit;
boolean dFruit;
private SlotMachineReel left = new SlotMachineReel();
private SlotMachineReel center = new SlotMachineReel();
private SlotMachineReel right = new SlotMachineReel();
public SlotMachine(){
this.left = left;
this.center = center;
this.right = right;
}
public void pullHandle(){
left.spin();
center.spin();
right.spin();
}
public String toString(){
return (this.left.getFace() + " | " + this.center.getFace() + " | " + this.right.getFace());
}
/**
* Returns the payout multiplier for the combination of
* faces currently on the front of this slot machine.
* <p>
* The payout table is given below. In this table,
* "fruit" means CHERRY, MELON, or LEMON;
* # means a symbol that matches one of the other 3 symbols;
* $ means a unique symbol (does not match any other shown); and
* ? means any symbol).
*
* <pre>
* REEL FACES PAYOUT FREQUENCY DESCRIPTION
* ------------------------ ------ ----------- -----------------------------
* COIN COIN COIN = 70x (* 1 = 70) = Coin JACKPOT
* SEVEN SEVEN SEVEN = 21x (* 1 = 21) = Triple 7s
* # # # = 7x (* 4 = 28) = Three of a Kind
* $fruit $fruit $fruit = 5x (* 6 = 30) = Fruit Medley (1 of each fruit)
* #fruit COIN #fruit = 3x (* 3 = 9) = Coin w/ Matching Fruit Pair
* # COIN # = 2x (* 2 = 4) = Coin w/ Matching non-fruit Pair
* ? COIN ? = 1x (*30 = 30) = Coin
* </pre>
* <p>
* Note that, for any payouts involving a single coin, the COIN must be
* showing on the center reel (just as shown above).
* <p>
* Since this slot machine earns 216 tokens per cycle through all
* permutations, but pays out only 192 tokens for the same cycle,
* it has a ~89% payout rate.
* <p>
* Returns a number between 0 and 70 as given in the PAYOUT column above.
* Returns 0 if no payout match is found, meaning the player lost his
* initial bet.
*/
public boolean isFruit(){
if ((left.equals("Cherry"))||(left.equals("Lemon"))
||(left.equals("Watermelon"))){
return lFruit = true;
}
if ((right.equals("Cherry"))||(right.equals("Lemon"))
||(right.equals("Watermelon"))){
return rFruit = true;
}
if ((center.equals("Cherry"))||(center.equals("Lemon"))
||(center.equals("Watermelon"))){
return cFruit = true;
}
}
public int getPayout(){
//finds if the reels are fruits
//If the center reel is a coin
if (center.equals("Coin")){
if (left.equals("Coin")&&(right.equals("Coin"))){
return 70;
}
//checks left and right reels
if ((lFruit)&&(rFruit)){
if (this.left.equals(right)){
return 3;
}
}
if (this.left.equals(this.right)){
return 2;
}
if (center.equals("Coin")){
return 1;
}
}
if ((lFruit)&&(cFruit)&&(rFruit)){
if (!(left.equals(center))&&!(center.equals(right))&&!(right.equals(left))
&&!(center.equals(left))){
return 5;
}
}
if (this.left.equals(center)){
if (this.left.equals(right)){
if (this.left.equals("7")){
return 21;
}
if(!(this.left.equals("7"))){
return 7;
}
}
}
}
}
```

*Edited 6 Years Ago by baldturtle*: n/a