Advertisement
zharry

ICS3U1 - Rock, Papers, Scissor, Lizard, Spock Game

Oct 1st, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. /**
  2.  * Random Project By: Harry
  3.  * For:               ICS3U1 - Assignment 10, Ms.Strelkovska
  4.  * Description:       Make a rock, paper, scissor, lizard, spock game.
  5.  * Personal Goal:     Use as little logical lines as possible!
  6.  * Date:              Oct. 1, 2016
  7.  *
  8.  */
  9.  
  10. public class Assignment10_Ex1_Min {
  11.  
  12.     public static void main(String[] args) {
  13.  
  14.         System.out.println("Enter your throw (0=Rock, 1=Paper, 2=Scissor, 3=Lizard, 4=Spock): ");
  15.         int m = new java.util.Scanner(System.in).nextInt(), c = (int) (Math.random() * 5);
  16.         System.out.println("Player thows " + new String[]{"Rock","Paper","Scissor","Lizard","Spock"}[m] + "\nComputer thows " + new String[]{"Rock","Paper","Scissor","Lizard","Spock"}[c] + "\n" + (m == c ? "You Tie!" : (((~(new int[]{12,17,10,18,5}[m] | new int[]{12,17,10,18,5}[m]) & ((1 << 5) - 1)) & new int[]{1,2,4,8,16}[m]) == new int[]{1,2,4,8,16}[m] ? true : false) ? "You Win!" : "Computer Wins!"));
  17.  
  18.     }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement