We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package com.example.gamblingapp;
import android.os.Bundle; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import android.view.View; import androidx.appcompat.app.AppCompatActivity; import java.util.Random;
public class SlotMachineActivity extends AppCompatActivity {
private ImageView slot1, slot2, slot3; private TextView resultText; private Button spinButton; private int[] images = {R.drawable.slot1, R.drawable.slot2, R.drawable.slot3}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_slot_machine); slot1 = findViewById(R.id.slot1); slot2 = findViewById(R.id.slot2); slot3 = findViewById(R.id.slot3); resultText = findViewById(R.id.resultText); spinButton = findViewById(R.id.spinButton); spinButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { spinSlots(); } }); } private void spinSlots() { Random random = new Random(); int slot1Result = random.nextInt(images.length); int slot2Result = random.nextInt(images.length); int slot3Result = random.nextInt(images.length); slot1.setImageResource(images[slot1Result]); slot2.setImageResource(images[slot2Result]); slot3.setImageResource(images[slot3Result]); if (slot1Result == slot2Result && slot2Result == slot3Result) { resultText.setText("You Win!"); } else { resultText.setText("Try Again!"); } }
}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
package com.example.gamblingapp;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Random;
public class SlotMachineActivity extends AppCompatActivity {
}
The text was updated successfully, but these errors were encountered: