android / android/search-samples
Gambling
- Dominant language
- Kotlin
- Stars
- 94
- Forks
- 81
- PR merge metrics
- No merged PRs in 30d
Description
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!");
}
}
}
Contributor guide
Research direction
The issue only provides a SlotMachineActivity code snippet and references the activity_slot_machine layout; it names no repository file, test, or requested change. Start by locating those entry points and clarifying the intended outcome, because completion cannot be defined from the issue alone.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 10/100