QuestionQuestion

Write a Rock, Paper, Scissors program in the language of your choice. User plays computer. User should have a 40% probability of winning each round.

Optional: Write a CREATE TABLE MySQL statement that could be used to save the results of each round.

Show your thought process, knowledge of a programming language, and adherence to standards.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.awt.event.ActionListener;

import javax.swing.*;


public class RockPaperScissors {
public static ImageIcon[] icons = {new ImageIcon("Rock.png"), //FIle names
new ImageIcon("Scissors.png"),
new ImageIcon("Paper.png")};
public static String[] names = {"Rock", "Scissors", "Paper"};
//Names of plays
private static JButton rock, paper, scissors; //Stuff for GUI
private static JLabel player, computer, playerImage, computerImage, winnerLabel;
private static JPanel buttons, images;
private static JFrame frame;
private static MySQL sql;

public RockPaperScissors()
{
sql = new MySQL(); //Start up the sql connection
frame = new JFrame("Rock Paper Scissors"); //Create frame
buttons = new JPanel(new GridLayout(1, 3)); //Initialize panels
images = new JPanel(new GridBagLayout());
winnerLabel = new JLabel("Winner: ");
GridBagConstraints c = new GridBagConstraints();
rock = new JButton("Rock");
rock.addActionListener(new ActionListener() { //Add listener for rock button
public void actionPerformed(ActionEvent e)
{
int choice = 0; //CHoice is 0 for rock
String winner;
int computerChoice = rockPaperScissors(choice); //Play game
playerImage.setIcon(icons[choice]);...

By purchasing this solution you'll be able to access the following files:
Solution.java.

$60.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats