Results 1 to 3 of 3
Thread: Eclipse Breakout Program
- 07-12-2012, 01:54 AM #1
Member
- Join Date
- Jul 2012
- Posts
- 4
- Rep Power
- 0
Eclipse Breakout Program
Hi,
I am currently trying to teach myself Java using eclipse and course material provided free from Stanford, the course is CS106a.
Ive been getting on fine but am now getting an unexpected error at the very start of the next assignment. The code is below, everything up to the run method is provided as a start to the program so can only assume it is correct. However whenever I try to add a new method eclipse keeps giving me error messages that to be honest I don't understand or know how to fix.
The errors are below,
- Multiple markers at this line
- Syntax error on token "void", @ expected
- Syntax error, insert "enum Identifier" to complete EnumHeader
I expect it will just be something obvious I'm missing but would be grateful if someone could help point it out to me.
Thanks.
/*
* File: Breakout.java
* -------------------
* Name:
* Section Leader:
*
* This file will eventually implement the game of Breakout.
*/
package Assignment3;
import acm.graphics.*;
import acm.program.*;
import acm.util.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Breakout extends GraphicsProgram {
/** Width and height of application window in pixels */
public static final int APPLICATION_WIDTH = 400;
public static final int APPLICATION_HEIGHT = 600;
/** Dimensions of game board (usually the same) */
private static final int WIDTH = APPLICATION_WIDTH;
private static final int HEIGHT = APPLICATION_HEIGHT;
/** Dimensions of the paddle */
private static final int PADDLE_WIDTH = 60;
private static final int PADDLE_HEIGHT = 10;
/** Offset of the paddle up from the bottom */
private static final int PADDLE_Y_OFFSET = 30;
/** Number of bricks per row */
private static final int NBRICKS_PER_ROW = 10;
/** Number of rows of bricks */
private static final int NBRICK_ROWS = 10;
/** Separation between bricks */
private static final int BRICK_SEP = 4;
/** Width of a brick */
private static final int BRICK_WIDTH =
(WIDTH - (NBRICKS_PER_ROW - 1) * BRICK_SEP) / NBRICKS_PER_ROW;
/** Height of a brick */
private static final int BRICK_HEIGHT = 8;
/** Radius of the ball in pixels */
private static final int BALL_RADIUS = 10;
/** Offset of the top brick row from the top */
private static final int BRICK_Y_OFFSET = 70;
/** Number of turns */
private static final int NTURNS = 3;
/* Method: run() */
/** Runs the Breakout program. */
public void run()
{
setSize(700, 500); // Sets the size of the canvas
private void brickCreator() - Multiple markers at this line
- Syntax error on token "void", @ expected
- Syntax error, insert "enum Identifier" to complete EnumHeader
{
// body of method
}
}
}
- 07-12-2012, 09:36 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Eclipse Breakout Program
Please use [code] tags [/code] when posting code.
Ensure your indentation is correct as well, because that should show that you have tried to declare a method inside another method.Please do not ask for code as refusal often offends.
- 07-13-2012, 10:37 AM #3
Member
- Join Date
- Jul 2012
- Posts
- 4
- Rep Power
- 0
Re: Eclipse Breakout Program
Oops, pretty obvious now I see it!
I am using Eclipse which does indent automatically although I do sometimes change it, think ill stick to default in future. The code I copied did have indentation but when I pasted it in it changed to the version shown above. I'll be sure to usewhen posting in future.Java Code:tags
Thanks for taking the time to reply.
Similar Threads
-
Eclipse Breakout Program
By mikle81 in forum EclipseReplies: 1Last Post: 07-12-2012, 09:34 AM -
Breakout Assignment from CS106a
By tech8462 in forum New To JavaReplies: 13Last Post: 10-09-2011, 03:38 AM -
Need help with Breakout game
By tfitz666 in forum New To JavaReplies: 9Last Post: 03-22-2010, 05:26 AM -
Breakout Game code help.
By Ceasar in forum New To JavaReplies: 6Last Post: 10-10-2009, 01:30 AM -
Another Breakout question
By jumpstart in forum New To JavaReplies: 3Last Post: 07-29-2009, 04:48 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks