Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: cannot find symbol

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default cannot find symbol

    import java.awt.event.*;
    import javax.swing.*;
    import tict.TicTGui;
     
    import tict.TicTGui;
     
     public class TicT 
    {
    	/*	Variables*/
        private javax.swing.JButton button1;
        private javax.swing.JButton button2;
        private javax.swing.JButton button3;
        private javax.swing.JButton button4;
        private javax.swing.JButton button5;
        private javax.swing.JButton button6;
        private javax.swing.JButton button7;
        private javax.swing.JButton button8;
        private javax.swing.JButton button9;
        private javax.swing.JFrame jFrame1;
     
        private String letter = "";
        public static int count = 0;
     
        /*Make The Window Visible*/
         public void run()
                {
                    new TicTGui().setVisible(true);
                    setCount(1);
     
                }
         // constructor that accepts a TicTGui object
     
        public TicT( TicTGui ticTGui )
        {
            this.ticTGui = ticTGui;
     
        } // end constructor
     
     
     
        private void setCount(int i)
        {
            throw new UnsupportedOperationException("Not yet implemented");
        }
     
    	/*Calculate Who's Turn It Is*/
        public int  WhoToPlay()
        {
     
            if(count == 1 || count == 3 || count == 5 || count == 7 || count == 9|| count == 11)
            {
                letter = "X";
     
            } else
            		if(count == 2 || count == 4 || count == 6 || count == 8 || count == 10)
            {
                letter = "O";
            }
    		return count;
        }
     
    	/*checking who plays*/
       	public void MakeYourMove(int count)
    	{
     
     
        	for(int i=0;i<=9;i++)
        	{
     
        		if(count==1)
        		{
    			 String input = JOptionPane.showInputDialog("welcome  you will take X and computer wiil take O \n Please ENTER number you want to play ");
            		 int pawn = Integer.parseInt(input);
                    //set letter  to choosen buttons
                    switch (input)
                    {
     
                        case "1":
                            ticTGui.setButton1Text( "X" );
                            ticTGui.setButton1Enabled( false );
                            break;
                        case "2":
                            ticTGui.setButton2Text( "X" );
                            ticTGui.setButton2Enabled( false );
                            break;
     
                        default:
                            JOptionPane.showInputDialog("Sorry invalid number entered Please enter a number from 1 to 9 \n Press enter to procced ");
                            break;
                    }
    		    	}
     
    		    	//generating a number to be played by computer
              		  int ran = 1 + (int)(Math.random() * 9);
    		    	//else
    		    		if(count==2)
    		    		{
    		    			 if (ran==1)
    		        		{
                                                button1.setText("O");
    				            button1.setEnabled(false);
     
    		       			 }
    				         else
    				         	if(ran==2)
    				       	{
    				             button2.setText("O");
    				             button2.setEnabled(false);
    				        }
    				         else
    				         	if(ran==3)
    				       	{
    				             button3.setText("0");
    				             button3.setEnabled(false);
    				        }
    				         else
    				         	if(ran==4)
    				       	{
    				             button4.setText("0");
    				             button4.setEnabled(false);
    				        }
    				         else
    				         	if(ran==5)
    				       	{
    				            button5.setText("0");
    				            button5.setEnabled(false);
    				        }
    				         else
    				         	if(ran==6)
    				       	{
    				             button6.setText("O");
    				             button6.setEnabled(false);
    				        }
    				         else
    				         	if(ran==7)
    				       	{
    				             button7.setText("X");
    				             button7.setEnabled(false);
    				        }
    				         else
    				         	if(ran==8)
    				       	{
    				             button8.setText("X");
    				             button8.setEnabled(false);
    				        }
    				         else
    				         	if(ran==9)
    				       	{
    				             button9.setText(letter);
    				             button9.setEnabled(false);
    				    	}
     
        				}
    	}
    	}
    	  public static void main(String args[])
        {
            /*
             * Create and display the form on the EDT
             */
            java.awt.EventQueue.invokeLater(new Runnable()
            {
     
                public void run() 
                {
                    new TicTGui();
                }
            });
     
        } // end method main()
     
    }

    why m i getting ann error"cannot find symbol TicTGui " where i am creating constructor that accepts a TicTGui object
    as well as in my switch statements " ticTGui.setButton1Text( "X" ); "
    "ticTGui.setButton1Enabled( false );"


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: cannot find symbol

    With the 'this' keyword, the constructor indicates that an instance variable, ticTGui, exists, but the error is telling you that it can't find that ticTGui was declared. All you have to do is declare it as you've done your other instance variables, "letter", "count", etc.:

    private TicTGui ticTGui;

  3. #3
    Junior Member
    Join Date
    May 2013
    Location
    Durban South Africa
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: cannot find symbol

    man TicTGui is not declared & i code yami le yang casula

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: cannot find symbol

    I hope that means I helped.

Similar Threads

  1. [SOLVED] cannot find symbol
    By ATIBA SHEIKH in forum What's Wrong With My Code?
    Replies: 12
    Last Post: December 26th, 2012, 03:28 AM
  2. [SOLVED] Cannot Find Symbol
    By ChicoTheMan94 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 25th, 2012, 02:46 PM
  3. cannot find symbol
    By lanpan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 1st, 2012, 08:13 AM
  4. Cannot find symbol
    By waarten in forum What's Wrong With My Code?
    Replies: 18
    Last Post: January 11th, 2012, 03:15 PM
  5. Cannot find symbol?
    By stealthmonkey in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 10th, 2010, 10:02 PM