You are on page 1of 7
a om = ee |e ae emcees é suoneogpeds seed somod 1 srmod z narmeypede Jove! | ; ea kr |, len C poo 0 sNBEP 3 spy se srr aos wed o mee] S/ fg sour paw spans spon stene uredong io cele swwod or ‘aimed st ‘urosBonct 9 ae ipwobry 4 ao FEM 8h ior Stop Qt shen Ee Ye Bo TG POUL. se jee * plays a game of Rock Paper Scissors anes + Fob. 20, 2019 " import java.util.*; import Java.awt -inage.Bufferedinago; import java.io.File; import java. io.10Exceptions import javax.inageio. Imagel0; import Javax swing. Inagelcon; import javax.awing.JPrane; import javax.ewing.JLabel; import java.io. import Sun.audio*; public class RockPaperScissors t Public static void main(string{) args} throws Exception{ Scanner console= new Scannex (System. in); String again= * ") while (!again.equalsignoreCase| ("exit"))){ //goes again if they do not put exit String userChoice= choice (); rosults (userChoice, conputerChoice(}); //pulls the results, and gets the user's choice A (userChoice.equalsTgnorecase ("coachkelley") || usexChoice.equalstgnorecase ("Coach Kelley")) | music? ()7 againg Mexitty Systen.out.printin ("By playing Coach Kelley, you are automatically the WINNER!*) ; y it(luserchoice.equals ("rock") && luserchoice. equal sTgnorecase ("scissors") && luserChoice.equalsTgnoreCase ("paper") && luserchoice equalstgnoreCase ("CoachKelley") && juserchoice.equalsignoreCase ("Coach Kelley") ) { Systen.out.printin (Miley Pal, You Just Blow tn From Stupid own?") stupidtown() agains "exit"; music(); , it(usercnoice equals ("rock") Iuserchoice equal sIgnoreCase ("scissors") | lusexChoice .equalsTgnorecase (mpapez")) ( System.out.printin ("Would you like to go again? Type EXIT to stop." ‘again= console.next (); //they choose if they want to go again System.out.printin(™\n"); , D d public static String choice!) ( ‘Scanner console= new Scanner (Systen.in) System-cut.printin("choose Rock, Paper, ox Scissors.) String cholee-console.next ()//they choose their play return choices d public static String compaterchoice () { Random randenew Random () int compthoicesrand.nextInt (3); //chooses a random number between land String computerchoice; if (compchoice==1){ ‘compliterchoice= *Rock"://if number ts one, computer chooses rock , else if (compcnoice += 2) ( ‘conputerchoice= "Paper"? //if number is two, computer chooses paper , elset computerchoices"scissors; //1f number is zero, computer chooses Scissoers , return computerchoice: 1 Public static void results (string choice, string compChoice] throws roException( ‘System-cut-printin(™\n") iF (choice.equalsignorecase ("rock") ( LE (compChoice.equalsignorecase ("rock") System.oul.printin("the computer chose ROCK, therefore it was a TIE"); » else if (compchoice.equalsignorecase ("paper")) { System.out.printin("The computer chose PAPER, therefore you are the LOSER) ; ) elset System.out.println ("the computer chose ScIssoRs, therefore you are the WINNER") ) : else if (choice. equalstgnorecase ("paper") | { LE (compChoice. equals Tgnorecase ("rock") } | System.out.printin("The computer chose ROCK, therefore you are the WINNER"); } else if(compchoice.equalstgnorecase ("paper") {

You might also like