import java.util.Random;
import java.util.Scanner;

public class PRS
 {
        public static void main (String args[])
    {
            Scanner sc=new Scanner(System.in); 
             String playerMove,playAgain;
             int p=0,c=0;
    while(true)
    {
            System.out.print('\\u000C');     
            String[] rps ={"r","p","s"};
            String computerMove = rps[new Random().nextInt(rps.length)];
             while (true)
            {
        
             System.out.println("Please enter your move(r for Rock,p for Paper or s for Sissior)");
             playerMove = sc.nextLine();
              if(playerMove.equals("r")||playerMove.equals("p")||playerMove.equals("s"))
                {
                break;         
                }
                 System.out.println(playerMove + " is not a valid move.");
            }
        System.out.println("Computer played: " + computerMove);
        if(computerMove.equals(playerMove))
        {
            System.out.println("The game was tie!"); 
             System.out.println("Your point= " + p + " and Computer point= " + c);
        }
        else if(playerMove.equals("p"))
        {
            if(computerMove.equals("r"))
            { 
                p++;
                System.out.println("You win!");
                System.out.println("Your point= " + p + " and Computer point= " + c);
            }
                 if(computerMove.equals("s"))
                 { c++;
                     System.out.println("You lose!"); 
                      System.out.println("Your point= " + p + " and Computer point= " + c);
                    }
        }           
        else if(playerMove.equals("r"))
        {
            if(computerMove.equals("p"))
            { p++;
                System.out.println("You win!"); 
                 System.out.println("Your point= " + p + " and Computer point= " + c);
            }
                 if(computerMove.equals("s"))
                   { p++;
                     System.out.println("You win!"); 
                      System.out.println("Your point= " + p + " and Computer point= " + c);
                    }
        }  
        else if(playerMove.equals("s"))
        {
            if(computerMove.equals("p"))
            { p++;
                System.out.println("You win!"); 
                 System.out.println("Your point= " + p + " and Computer point= " + c);
            }
                 if(computerMove.equals("r"))
                     { c++;
                     System.out.println("You lose!"); 
                      System.out.println("Your point= " + p + " and Computer point= " + c);
                     }
            } 
             System.out.println("Do you want to play again? (y/n)");
              playAgain = sc.nextLine();
              if( !playAgain.equals("y")) 
            {   
            break;
            }   
        }System.out.println("Thanks for playing.");
            System.out.println("Your point " + p);
                System.out.println("Computer point " + c);
                if(p>c)
                {
                    System.out.println("Congrats! You won");
                }
                else if(p<c)
                {
                    System.out.println("Sorry, you lose ");
                }
                else {System.out.println("This game  was tie");}
    }   
}