Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- button.setOnClickListener(new View.OnClickListener() {
- int menCount = 0;
- int girlCount = 0;
- int count = 0;
- @Override
- public void onClick(View view) {
- count++;
- // List of boy names
- List<String> boyNames = Arrays.asList("João", "Pedro", "Carlos", "Lucas", "Rafael");
- // List of girl names
- List<String> girlNames = Arrays.asList("Maria", "Ana", "Juliana", "Carla", "Mariana");
- Random rand = new Random();
- // Generate a random number between 0 and 4
- int randomNumber = rand.nextInt(5);
- // Choose a random boy or girl name
- String randomName = rand.nextBoolean() ? boyNames.get(randomNumber) : girlNames.get(randomNumber);
- textView.setText(randomName);
- if (boyNames.contains(randomName)) {
- menCount++;
- } else {
- girlCount++;
- }
- if(count == 10){
- if(menCount>girlCount){
- Toast.makeText(getApplicationContext(), "NOME DE HOMEM SAIU MAIS", Toast.LENGTH_SHORT).show();
- }else{
- Toast.makeText(getApplicationContext(), "NOME DE MULHER SAIU MAIS", Toast.LENGTH_SHORT).show();
- }
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement