Initial commit

This commit is contained in:
Cayden Lee Brackett 2024-11-16 17:35:41 -05:00
commit 472a011ffc

54
Rock_paper.java Normal file
View File

@ -0,0 +1,54 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Rock_paper {
static boolean rock = false;
static boolean scissors = false;
static boolean paper = false;
boolean airock = false;
boolean aiscissors = false;
boolean aipaper = false;
public static void main(String[] args) {
JFrame frame = new JFrame("rock paper scissors");
frame.setSize(300,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton rockbutton = new JButton("rock");
JButton paperbutton = new JButton("paper");
JButton sissorsButton = new JButton("sissors");
JPanel panel = new JPanel();
panel.add(rockbutton);
panel.add(paperbutton);
panel.add(sissorsButton);
rockbutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
rock = true;
if(rock == true) {
scissors = false;
paper = false;
System.out.println("rock is true");
};
}
});
paperbutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
paper = true;
if(paper == true) {
rock = false;
scissors = false;
System.out.println("paper is true");
};
}
});
frame.add(panel);
frame.setVisible(true);
}
}