/*    CS 111A - Craig Persiko - RPS.java
      Rock - Paper - Scissors - Homework 5 Solution
      This program plays the paper-rock-scissors game.
*/

import java.util.Scanner;


public class RPS
{
  public static void main(String[] args)
  {
    Scanner inputBuffer = new Scanner(System.in);
    String input;
    char move;
    int computer;
    final int P = 0, R = 1, S = 2;

    System.out.println("Welcome to Craig's Rock-Paper-Scissors Game");
    System.out.print("Please enter your move: ");
    input = inputBuffer.nextLine();
    move = input.charAt(0);

    computer = (int)(Math.random() * 3);

    switch (computer)
    {
      case P:
        System.out.println("Computer's move is Paper");
        break;

      case R:
        System.out.println("Computer's move is Rock");
        break;

      case S:
        System.out.println("Computer's move is Scissors");
        break;
    }

    if ((move == 'R' || move == 'r') && computer == S)
      System.out.println("You Win! Rock Breaks Scissors!!");
    else if ((move=='R' || move=='r') && computer == P)
      System.out.println("Computer Wins! Paper Covers Rock!!");
    else if ((move=='R' || move=='r') && computer == R)
      System.out.println("Tie!!");
    else if ((move=='P' || move=='p') && computer == S)
      System.out.println("Computer Wins! Scissors Cut Paper!!");
    else if ((move=='P'||move=='p') && computer == R)
      System.out.println("You Win! Paper Covers Rock!!");
    else if ((move=='P'||move=='p') && computer == P)
      System.out.println("Tie!!");
    else if ((move=='S'||move=='s') && computer == P)
      System.out.println("You Win! Scissors Cut Paper!!");
    else if ((move=='S'||move=='s') && computer == R)
      System.out.println("Computer Wins! Rock Breaks Scissors!!");
    else if ((move=='S'||move=='s') && computer == S)
      System.out.println("Tie!!");
    else
      System.out.println("Invalid move!!");
  }
}

/*  Sample Output:

[cpersiko@localhost cs111a]$ java RPS
Welcome to Craig's Rock-Paper-Scissors Game
Please enter your move: rock
Computer's move is Scissors
You Win! Rock Breaks Scissors!!
[cpersiko@localhost cs111a]$ java RPS
Welcome to Craig's Rock-Paper-Scissors Game
Please enter your move: r
Computer's move is Paper
Computer Wins! Paper Covers Rock!!
[cpersiko@localhost cs111a]$ java RPS
Welcome to Craig's Rock-Paper-Scissors Game
Please enter your move: P
Computer's move is Paper
Tie!!
[cpersiko@localhost cs111a]$ java RPS
Welcome to Craig's Rock-Paper-Scissors Game
Please enter your move: paper
Computer's move is Scissors
Computer Wins! Scissors Cut Paper!!
[cpersiko@localhost cs111a]$ java RPS
Welcome to Craig's Rock-Paper-Scissors Game
Please enter your move: Scissors
Computer's move is Paper
You Win! Scissors Cut Paper!!
[cpersiko@localhost cs111a]$ java RPS
Welcome to Craig's Rock-Paper-Scissors Game
Please enter your move: scissors
Computer's move is Paper
You Win! Scissors Cut Paper!!
[cpersiko@localhost cs111a]$ java RPS
Welcome to Craig's Rock-Paper-Scissors Game
Please enter your move: fish
Computer's move is Paper
Invalid move!!
[cpersiko@localhost cs111a]$ 

*/


syntax highlighted by Code2HTML, v. 0.9