import javax.swing.*;
import java.util.*;
public class LauraExamPartOne {
public static void main(String[] args) {
String input;
int playerChoice;
int compChoice;
System.out.println("Laura's CIS 256 Final Exam");
//need to implement a background or image for this part
input = JOptionPane.showInputDialog("This is my CIS 256 Final Exam. Lets play Rock, Paper, Scissors.\n" +
"Type 1 for Rock, 2 for Paper, and 3 for Scissors, then press OK.\n" + "If you do not wish to play, please press Cancel now.");
playerChoice = Integer.parseInt(input);
Random someNum = new Random ();
autoChoice = someNum.nextInt(3);
if (playerChoice == 1 && autoChoice == 0)
JOptionPane.showMessageDialog(null, "It's a Tie! Would you like to play again?");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
else if (playerChoice == 1 && autoChoice == 1)
JOptionPane.showMessageDialog(null, "Paper covers Rock. You lose! Would you like to play again?");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
else if (playerChoice == 1 && autoChoice == 2)
JOptionPane.showMessageDialog(null, "Rock breaks Scissors. You win! Would you like to play again?");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
else if (playerChoice == 2 && autoChoice == 0)
JOptionPane.showMessageDialog(null, "Paper covers Rock. You win! Would you like to play again?");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
else if (playerChoice == 2 && autoChoice == 1)
JOptionPane.showMessageDialog(null, "It's a Tie! Would you like to play again?");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
else if (playerChoice == 2 && autoChoice == 2)
JOptionPane.showMessageDialog(null, "Scissors cut Paper. You lose! Would you like to play again?");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
else if (playerChoice == 3 && autoChoice == 0)
JOptionPane.showMessageDialog(null, "Rock breaks Scissors. You lose! Would you like to play again?");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
else if (playerChoice == 3 && autoChoice == 1)
JOptionPane.showMessageDialog(null, "Scissors cut Paper. You win! Would you like to play again?");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
else if (playerChoice == 3 && autoChoice == 2)
JOptionPane.showMessageDialog(null, "It's a Tie! Would you like to play again?");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
else if (playerChoice > 3 || autoChoice > 3)
JOptionPane.showMessageDialog(null, "HEY! That's not a valid choice, please try again.");
//needs a "Play Again?" button that starts the game over if pressed
//needs an "End Game." button that starts the game over if pressed
}
}
This post has been edited by Stressed_Programming_Student: 12 December 2009 - 07:53 PM

New Topic/Question
Reply




MultiQuote




|