Your SlideShare is downloading. ×
Pingame
Pingame
Pingame
Pingame
Pingame
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
332
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. /* CODE COMPILED AND CREATED BY    SHALABH PAREEK    LECTURER    GEETANJALI INSTITUTE OF TECHNICAL STUDIES    UDAIPUR(RAJ.) */ import java.awt.*; import java.awt.event.*; import javax.swing.*; class PinGame extends JFrame implements ActionListener {    JTextField [] tf ;    JLabel [] tl;    JButton submit,clear;    JLabel lscore;    JTextField tfscore ;    String [] stf   = {"X1","X2","RESET OUT","SOD","SID",                        "TRAP","RST 7.5","RST 6.5","RST 5.5","INTR","INTA",                        "AD0","AD1","AD2","AD3","AD4","AD5","AD6","AD7","VSS",                        "A8","A9","A10","A11","A12","A13","A14","A15",                        "S0","ALE","WR","RD","S1","IO/M","READY","RESET IN",                        "CLK (OUT)","HLDA","HOLD","VCC" };    PinGame ()    {         super("Pin Diagram ­ 8085");         setLayout(null);         setBounds(0,0,1100,750);         setBackground(Color.gray); JLabel in1 = new JLabel("INSTRUCTIONS :"); JLabel in2 = new JLabel("1. ENTER NAME OF EACH PIN IN GIVEN  TEXTFIELD"); JLabel in3 = new JLabel("2. YOU WILL EARN ONE POINT FOR EVERY RIGHT  ANSWER");         JLabel in4 = new JLabel("3. NO NEGATIVE MARKING");         JLabel in5 = new JLabel("4. ENTER PIN NAMES IN UPPERCASE ONLY ");         JLabel in6 = new JLabel("5. WRITE ACTIVE LOW SIGNALS WITHOUT COMPLEMENT  SIGN ");         JLabel in7 = new JLabel("6. WHEN DONE CLICK ON SUBMIT TO GET RESULT");         in1.setBounds(550,10,400,80 );         in2.setBounds(550,50,400,80 );         in3.setBounds(550,90,400,80 );         in4.setBounds(550,130,400,80 );
  • 2.         in5.setBounds(550,170,400,80 );         in6.setBounds(550,210,400,80 );         in7.setBounds(550,250,400,80 );         add(in1);         add(in2);         add(in3);         add(in4);         add(in5);         add(in6);         add(in7);         Font f1 = new Font ("Bookman Old Style",Font.BOLD,16);         tf = new JTextField[40];         tl = new JLabel[40];         submit = new JButton("SUBMIT");         clear  = new JButton("CLEAR");         lscore = new JLabel("YOU SCORED = " );         tfscore = new JTextField();         submit.setBounds(450,400,80,20 );         lscore.setBounds(600,400,120,20 );         tfscore.setBounds(750,400,80,20 );         clear.setBounds(450,500,80,20 );         add(submit);         add(lscore);         add(tfscore);         add(clear);         submit.addActionListener(this);         clear.addActionListener(this);          String[] sl = {"1","2","3","4","5","6","7","8","9","10",                          "11","12","13","14","15","16","17","18","19","20",                          "21","22","23","24","25","26","27","28","29","30",                          "31","32","33","34","35","36","37","38","39","40"};         int tfx = 20, tfy = 10,length = 80,width = 28;         for(int i = 0; i<20;i++)         {             tf[i] = new JTextField();             tf[i].setBounds(tfx,tfy,length,width);             tfy = tfy + 30;             add(tf[i]);
  • 3.         }         tfx = 325;         for(int i = 20; i<40;i++)         {             tfy = tfy ­ 30;             tf[i] = new JTextField();             tf[i].setBounds(tfx,tfy,length,width);             add(tf[i]);         }          for(int i = 0; i<40;i++)         {             tf[i].setFont(new Font ("Century Schoolbook",Font.BOLD,12));         }         int lx = 150, ly = 10,llength = 80,lwidth = 28;         for(int i = 0; i<20;i++)         {             tl[i] = new JLabel(sl[i]);             tl[i].setBounds(lx,ly,llength,lwidth);             ly = ly + 30;             add(tl[i]);         }         lx = 250;         for(int i = 20; i<40;i++)         {             ly = ly ­ 30;             tl[i] = new JLabel(sl[i]);             tl[i].setBounds(lx,ly,llength,lwidth);             add(tl[i]);         }         addWindowListener(new END());         setVisible(true) ;     }     public static void main(String[] args)     {           new PinGame();     }
  • 4.     public void actionPerformed(ActionEvent ae)     {        int score = 0;     if(ae.getSource()==submit)     {        String[] s3 = new String[40];        for(int i = 0;i<40;i++)         {          s3[i] = tf[i].getText();         // s3[i] = String.toUpperCase(s3[i]);         }        for (int i = 0;i<40;i++)         {            if( s3[i].equals(stf[i]) )             {               score++;             }            else             {               tf[i].setText("TRY AGAIN");             }         }         Integer i1 = new Integer(score);         tfscore.setText(i1.toString());     }     if(ae.getSource()==clear)     {       for(int i = 0; i<40;i++)         {             tfscore.setText("");             tf[i].setText("");         }     }     }
  • 5. } class END extends WindowAdapter {     public void windowClosing(WindowEvent e)     {       System.exit(0);     } }

×