I need help with this code!
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Random; public class RockPaperScissorsPanel extends JPanel { private JLabel quote; private JRadioButton rock, paper, scissors; private String rockQuote, paperQuote, scissorsQuote; private int userIn = -1, compIn = -1, wins=0, ties=0, losses=0, again=100; public RockPaperScissorsPanel() { rockQuote = "Rock"; paperQuote = "Paper"; scissorsQuote = "Scissors"; quote = new JLabel("Choice:"); quote.setFont(new Font("Helvetica", Font.BOLD, 24)); rock = new JRadioButton("Rock"); rock.setBackground(Color.white); paper = new JRadioButton("Paper"); paper.setBackground(Color.white); scissors = new JRadioButton("Scissors"); scissors.setBackground(Color.white); ButtonGroup group = new ButtonGroup(); group.add(rock); group.add(paper); group.add(scissors); RockPaperScissors listener = new RockPaperScissors(); rock.addActionListener(listener); ppaper.addActionListener(listener); scissors.addActionListener(listener); add(quote); add(rock); add(paper); add(scissors); setBackground(Color.white); setPreferredSize(new Dimension(320, 600)); } private class RockPaperScissorsListener implements ActionListener { public void actionPerformed(ActionEvent event) { Object source = event.getSource(); if (source == rock) { quote.setText(rockQuote); userIn = 1; } if (source == paper) { quote.setText(paperQuote); userIn = 2; } if (source == scissors) { quote.setText(scissorsQuote); userIn = 3; } } Random generator = new Random(); compIn = generator.nextInt(3) + 1; switch (compIn) { case 1: compIn = rockQuote; break; case 2: compIn = paperQuote; break; case 3: compIn = scissorsQuote; break; } System.out.println("Your choice: " + userIn + " Computer choice: " + compIn); if(userIn == compIn) { System.out.println("Tie"); ties++; } else { if((userIn ==1 && compIn ==3)||(userIn == 2 && compIn == 1)||(userIn==3 && compIn== 2)) { System.out.println("You win"); wins++; } else if((userIn==1 && compIn ==2) || (userIn ==2 && compIn == 3) || (userIn ==3 && compIn ==1)) { System.out.println("You lose"); losses++; } } } } }
If anybody could lend some assistance, that would be great!