Initial commit
This commit is contained in:
commit
472a011ffc
54
Rock_paper.java
Normal file
54
Rock_paper.java
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user