| help with quiz 
 
	 
	
		| Author | Message |   
		| khanzaman 
 
 
 
 
 | 
			
				|  Posted: Sun Jan 18, 2009 2:02 am    Post subject: help with quiz |  |   
				| 
 |  
				| I have a problem with my quiz its about adding the score i have radiobutton in each question but when i add an action where is their right they it adds one to their score and one to the answer so like this: 
 class .....
 
 
 	  | Java: |  	  | {
class quiz extends JFrame implements ActionListener
{
    //Score
   int  score=0 ;
   int  question=0 ;
    //question and answer
   String []  Q= {"QUESTION 1:What was the number one movie in the box office in 2008?" ," String [] A= {"
 India Jones and the Kingdom of the Crystal Skull"," The Dark Knight" 
 (then where the Jcomponents are added)
 ......................
 
 (then where question 1 method start)
 ....the frame then
 
 frame1_radio1=new JRadioButton(A[0]);//add Jradiobutton 1 to frame2(JFrame)
 frame1_radio1.setActionCommand("
 1");//adds an action to the radio button frame1_radio1.setFont(new Font("
 Times New  Roman",Font.PLAIN,18));//creates a Font for the radiobutton and sets it to radiobutton by the (name of font,style,size) frame1_radio1.setForeground(Color.white);//sets the foreground(text)colour to radiobutton
 frame1_radio1.setBackground(Color.black);//sets a background colour of radiobutton
 
 frame1_radio2=new JRadioButton(A[1]);//add Jradiobutton 2 to frame2(JFrame)
 frame1_radio2.setActionCommand("
 2");//adds an action to the radio button frame1_radio2.setFont(new Font("
 Times New  Roman",Font.PLAIN,18));//creates a Font for the radiobutton and sets it to radiobutton by the (name of font,style,size) frame1_radio2.setForeground(Color.white);//sets the foreground(text)colour to radiobutton
 frame1_radio2.setBackground(Color.black);//sets a background colour of radiobutton
 
 frame1_radio3=new JRadioButton(A[2]);//add Jradiobutton 3 to frame2(JFrame)
 frame1_radio3.setActionCommand("
 3");//adds an action to the radio button frame1_radio3.setFont(new Font("
 Times New  Roman",Font.PLAIN,18));//creates a Font for the radiobutton and sets it to radiobutton by the (name of font,style,size) frame1_radio3.setForeground(Color.white);//sets the foreground(text)colour to radiobutton
 frame1_radio3.setBackground(Color.black);//sets a background colour of radiobutton
 
 frame1_radio4=new JRadioButton(A[3]);//add Jradiobutton 4 to frame2(JFrame)
 frame1_radio4.setActionCommand("
 4");//adds an action to the radio button frame1_radio4.setFont(new Font("
 Times New  Roman",Font.PLAIN,18));//creates a Font for the radiobutton and sets it to radiobutton by the (name of font,style,size) frame1_radio4.setForeground(Color.white);//sets the foreground(text)colour to radiobutton
 frame1_radio4.setBackground(Color.black);//sets a background colour of button
 
 
 (then in the actionperformed method)
 
 //Question 1(method) {
 if(evt.getActionCommand().equals("
 2"))//if the action equals 2 then {//start if
 score++;//adds one to the score
 question++;//adds one to the question
 }//ends if
 else if (evt.getActionCommand().equals("
 1"+" 3"+" 4"))//if the action is equal to 1,3,4 {//start if
 question++;//adds one to the question
 }//ends if
 
 }
 | 
 
 
 but when the score and answer are printed out in the a new frame it says 0/0.
 
 only thing i could think of is that it is resetting the score and answer to 0 after every frame with a question.
 
 does anyone noe how to fix that problem
 ty
 
 Use syntax or code tags! - wtd
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| wtd 
 
 
 
 
 | 
			
				|  Posted: Sun Jan 18, 2009 1:47 pm    Post subject: RE:help with quiz |  |   
				| 
 |  
				| Hey look, I added syntax tags and now it looks all red.  Why is what? |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| khanzaman 
 
 
 
 
 | 
			
				|  Posted: Sun Jan 18, 2009 3:11 pm    Post subject: Re: help with quiz |  |   
				| 
 |  
				| i didnt copy my whole program i was just giving you an example of how my program looks and why it wasnt adding the score |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| wtd 
 
 
 
 
 | 
			
				|  Posted: Sun Jan 18, 2009 8:02 pm    Post subject: RE:help with quiz |  |   
				| 
 |  
				| And the part you did post is obviously broken, which is what I was pointing out. |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| deltatux 
 
  
 
 
 | 
			
				|  Posted: Sun Jan 18, 2009 8:35 pm    Post subject: RE:help with quiz |  |   
				| 
 |  
				| 	  | Java: |  	  | 
String [] Q= {"QUESTION 1:What was the number one movie in the box office in 2008?" ," String [] A= {"
 India Jones and the Kingdom of the Crystal Skull"," The Dark Knight" 
 | 
 
 I think you forgot to close the curly brackets here.
 
 deltatux
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| khanzaman 
 
 
 
 
 | 
			
				|  Posted: Sun Jan 18, 2009 9:20 pm    Post subject: Re: help with quiz |  |   
				| 
 |  
				| i knowwwww but i  just want to know why the score doesnt add i just quickly copied that piece and deleted some stuff to shortin it down for you if u want to see my whole program its veryyy long |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |