Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

identifier expected  RSS feed

 
Danny Broadwater
Ranch Hand
Posts: 65
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have an error on line 64 stating... error: <identifier> expected. On line 71 an error stating... cannot find symbol. Would ya'll help me figure out what is wrong with these 2 errors.

TicTacToeGUIGame



games.board





Thanks for your time and effort, Danny

 
Charles D. Ward
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
64: throw new what?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In line 64 the code tries to throw an Exception. It also does that in some other spots - what's the difference between line 64 and those other spots?

In line 71 you're calling 3 methods: Board.setCell, Cell.getRow and Cell.getColumn, and the compiler is not happy about that. Why might it not be happy?

You're still reusing class names from the Java API - JButton and BasicStroke. I'm not sure what redefining JButton is suppose to accomplish -did you mean to extend JButton instead?- but I'm 99% sure that you should just delete the BasicStroke class and use java.awt.BasicStroke instead.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder why you have those private inner classes, in lines 30-46.

Class TicTacToeGUlGame (sounds like TicTacToeGUIGame spelled wrong), class Cell and class c. What are those for?

I suspect that you are using an IDE and that sometimes you spell a name wrong, and the IDE suggests to automatically correct the error for you by making a private inner class. Don't do that. Remove those inner classes.

In line 62, for example, you are creating a new instance of the inner class TicTacToeGUlGame (NOT your class TicTacToeGUIGame). I don't think that is what you really wanted to do in line 62.

About the error in line 64: You suddenly have a statement to throw an exception inside an anonymous inner class, but outside of any method. That is not correct. Statements must always be inside a method.

In your second code sample (class Cell), you have an inner class called JButton. As I already said in your previous question, don't create classes that have the same name as classes in Java's standard library. It will lead to very confusing errors, if you think you're using the standard JButton class, but in reality you're using your own JButton class.

You also have a class BasicStroke in line 39 of your second code sample. What is that for? Remove it, and import java.awt.BasicStroke instead, because that is what I think you intended to use.
 
Danny Broadwater
Ranch Hand
Posts: 65
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I edited the 2 boards, I am still at a loss on what you are trying to tell me, but I am learning. Danny
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't edit your posts like that. Now all the previous posts make no sense any more, and neither you nor we can track the progress.

I agree with Jesper - I think your use of an IDE causes issues that make things much harder than they should be. The code now is a lot worse with all those inner classes. You've gotten rid of the BasicStroke class, but introduced several other classes that are even less helpful.

At this point my advice would be: power down the IDE, delete the code, and start from scratch using a basic code editor like Notepad++.
 
Danny Broadwater
Ranch Hand
Posts: 65
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thank you Danny
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!