Paper, rock, scissors (with classes)


Submit solution

Points: 10
Time limit: 5.0s
Memory limit: 256M

Author:
Problem types
Allowed languages
C#, Go, Java

Implementa les classes Game i Player a partir del següent codi:

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;


// escriu el codi aqui

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        scanner.useLocale(Locale.ENGLISH);

        Game game = new Game(new Player(0), new Player(0));

        int numRondas = scanner.nextInt();

        for (int i = 0; i < numRondas; i++) {
            String ronda = scanner.next();
            if(ronda.equals("@%") || ronda.equals("#@") || ronda.equals("%#")){
                game.player1.points++;
            } else if(ronda.equals("%@") || ronda.equals("@#") || ronda.equals("#%")){
                game.player2.points++;
            }
        }

        if(game.player1.points > game.player2.points){
            System.out.println("PLAYER 1 WINS");
        } else if(game.player2.points > game.player1.points){
            System.out.println("PLAYER 2 WINS");
        } else {
            System.out.println("TIE");
        }
    }
}

Input Format

-

Constraints

-

Output Format

-

Sample Input 0

4 ## @# %# %@

Sample Output 0

PLAYER 2 WINS

Sample Input 1

6 #@ %@ %# #% %@ @%

Sample Output 1

TIE

Sample Input 2

6 @% @% %# %# #% #@

Sample Output 2

PLAYER 1 WINS

Autoria: Gerard Falcó


Authorship: Gerard Falcó

CC BY-NC-SA 4.0