title: Why doesn't my if statement work?
body: <p>I have made an app in Android Studio.</p>
  
  <p>Quick summary: Its an app for kids that presents a random shape when the user starts the game. The user has 4 options to choose from where one shape is the correct shape. The user then needs to drag and drop the shape into the outline. A pic of an example is shown below. </p>
  
  <p><a href="https://i.stack.imgur.com/vqXdH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vqXdH.png" alt="MyGame"></a></p>
  
  <p>The problem is, I need 1 of the 4 shapes below to match the shape to be guessed. I have 2 sets of 18 shapes, the first set is the shape outline with the ? inside.</p>
  
  <pre><code>    int[] outlines = new int[] {R.drawable.outline_0, R.drawable.outline_1, R.drawable.outline_2,
              R.drawable.outline_3, R.drawable.outline_4, R.drawable.outline_5, R.drawable.outline_6,
              R.drawable.outline_7, R.drawable.outline_8, R.drawable.outline_9, R.drawable.outline_10,
              R.drawable.outline_11, R.drawable.outline_12, R.drawable.outline_13, R.drawable.outline_14,
              R.drawable.outline_15, R.drawable.outline_16,R.drawable.outline_17};
  </code></pre>
  
  <p>The second set is the actual coloured shapes with the faces.</p>
  
  <pre><code>    int[] images = new int[] {R.drawable.img_0, R.drawable.img_1, R.drawable.img_2, R.drawable.img_3, R.drawable.img_4,
      R.drawable.img_5, R.drawable.img_6, R.drawable.img_7, R.drawable.img_8, R.drawable.img_9, R.drawable.img_10,
              R.drawable.img_11, R.drawable.img_12, R.drawable.img_13, R.drawable.img_14, R.drawable.img_15, R.drawable.img_16,
              R.drawable.img_17};
  </code></pre>
  
  <p>I need some sort of function or statement where the 4 shapes in the bottom cannot be the same as well as 1 of the shapes corresponding to the shape that needs to be guessed. </p>
  
  <p>NOTE: outline_0 shape corresponds to img_0, outline_1 corresponds to img_1 etc.</p>
  
  <p>This is the whole code for this activity. </p>
  
  <pre><code>public class SecondActivity extends AppCompatActivity {
  
  int n;
  ImageView shape1, shape2, shape3, shape4, guessShape;
  ImageButton exit;
  Random rand = new Random();
  ImageView[] shapes = new ImageView[4];
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_second);
  
      shape1 = (ImageView) findViewById(R.id.shape1);
      shape2 = (ImageView) findViewById(R.id.shape2);
      shape3 = (ImageView) findViewById(R.id.shape3);
      shape4 = (ImageView) findViewById(R.id.shape4);
      guessShape = (ImageView) findViewById(R.id.guessShape);
      shapes[0] = shape1;
      shapes[1] = shape2;
      shapes[2] = shape3;
      shapes[3] = shape4;
  
      //store all the shapes in an array
      int[] images = new int[] {R.drawable.img_0, R.drawable.img_1, R.drawable.img_2, R.drawable.img_3, R.drawable.img_4,
      R.drawable.img_5, R.drawable.img_6, R.drawable.img_7, R.drawable.img_8, R.drawable.img_9, R.drawable.img_10,
              R.drawable.img_11, R.drawable.img_12, R.drawable.img_13, R.drawable.img_14, R.drawable.img_15, R.drawable.img_16,
              R.drawable.img_17};
  
      int[] outlines = new int[] {R.drawable.outline_0, R.drawable.outline_1, R.drawable.outline_2,
              R.drawable.outline_3, R.drawable.outline_4, R.drawable.outline_5, R.drawable.outline_6,
              R.drawable.outline_7, R.drawable.outline_8, R.drawable.outline_9, R.drawable.outline_10,
              R.drawable.outline_11, R.drawable.outline_12, R.drawable.outline_13, R.drawable.outline_14,
              R.drawable.outline_15, R.drawable.outline_16,R.drawable.outline_17};
  
      //generate random number between 0 and image.length
     int img1 = (int) Math.round((Math.random() * images.length));
      int img2 = (int) Math.round((Math.random() * images.length));
      int img3 = (int) Math.round((Math.random() * images.length));
      int img4 = (int) Math.round((Math.random() * images.length));
      int outlineID = (int) Math.round((Math.random() * outlines.length));
  
  
      //set the image
      guessShape.setBackgroundResource(outlines[outlineID]);
      shape1.setBackgroundResource(images[img1]);
      shape2.setBackgroundResource(images[img2]);
      shape3.setBackgroundResource(images[img3]);
      shape4.setBackgroundResource(images[img4]);
  
        //set tags for the imageViews
      guessShape.setTag("RandomImage");
      shape1.setTag("Shape1");
      shape2.setTag("Shape2");
      shape3.setTag("Shape3");
      shape4.setTag("Shape4");
  
      //1 of the 4 image views needs to match outline of the shape that needs to be guessed
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_0)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_0);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_1)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_1);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_2)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_2);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_3)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_3);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_4)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_4);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_5)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_5);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_6)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_6);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_7)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_7);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_8)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_8);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_9)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_9);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_10)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_10);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_11)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_11);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_12)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_12);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_13)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_13);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_14)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_14);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_15)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_15);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_16)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_16);
      }
      if(guessShape.getBackground().getConstantState().equals(R.drawable.outline_17)){
          int random = new Random().nextInt(shapes.length);
          shapes[random].setBackgroundResource(R.drawable.img_17);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <ol>
  <li>What am I doing wrong here? </li>
  <li>Why doesn't my if statements work for making sure one of the random shapes below corresponds to the shape to be guessed? </li>
  <li>How do I make sure that the 4 shapes in the bottom are different?</li>
  </ol>
  
  <p>Any tips to solve my problem would be great. Thank you! :)</p>