|
Replies:
6
-
Last Post:
Nov 23, 2008 2:29 PM
by: unokamlesh
|
Threads:
[
Previous
|
Next
]
|
|
|
|
|
|
Java assignment help
Posted:
Nov 9, 2008 1:31 PM
|
|
|
Hi there, I have an assignment due in a couple of days and I need some help. I don't have time to read a Java books. Plus, my teacher is useless as he can't explain anything...and the TAs are worst. My error is in line 145 (scroll down) saying "illegal start of expression". I didn't have this error before I added the movement command. Any help is greatly appreciated 
-------------------------------
import java.awt.*; import java.applet.*;
/* Part 0, CSC104 Assignment 2 Fall 08 * Where is Wall-e? */ public class Part5 extends Applet implements Runnable{
private Location ovalOffset; private Location pictureLocation; private Color color; private Oval oval; private Size size;
private Location ovalOffset2; private Color color2; private Oval oval2; private Size size2;
private Box neck; private Location neckOffset; private Color neckColor; private Size neckSize;
private Square bot; private Location botOffset; private Color botColor; private Size botSize;
private Oval eye; private Location eyeOffset; private Color eyeColor; private Size eyeSize;
private Oval eyes; private Location eyesOffset; private Color eyesColor; private Size eyesSize;
private Oval wheel; private Location wheelOffset; private Color wheelColor; private Size wheelSize;
private Oval wheels; private Location wheelsOffset; private Color wheelsColor; private Size wheelsSize;
int x=20; int y=10; Thread appletThread;
/* Initialize variables for an oval. */ public void init() {
pictureLocation = new Location(0, 0); ovalOffset = new Location(0, 0); color = new Color(0, 0, 0); size = new Size(100, 200); oval = new Oval(pictureLocation, ovalOffset, size, color);
ovalOffset2 = new Location(10,10); color2 = new Color(255, 255, 255); size2 = new Size(80, 180); oval2 = new Oval(pictureLocation, ovalOffset2, size2, color2);
neckOffset = new Location(87, 100); neckColor = new Color(0, 102, 92); neckSize = new Size(115, 22); neck = new Box(pictureLocation, neckOffset, neckSize, neckColor);
botOffset = new Location(0, 200); botColor = new Color(181, 84, 0); botSize = new Size(200, 200); bot = new Square(pictureLocation, botOffset, botSize, botColor);
eyeOffset = new Location(50, 10); eyeColor = new Color(0, 0, 0); eyeSize = new Size(80, 80); eye = new Oval(pictureLocation, eyeOffset, eyeSize, eyeColor);
eyesOffset = new Location(90,10 ); eyesColor = new Color(0, 0, 0); eyesSize = new Size(80, 80); eyes = new Oval(pictureLocation, eyesOffset, eyesSize, eyesColor);
wheelOffset = new Location(0,355 ); wheelColor = new Color(0, 0, 0); wheelSize = new Size(98, 98); wheel = new Oval(pictureLocation, wheelOffset, wheelSize, wheelColor);
wheelsOffset = new Location(100,355 ); wheelsColor = new Color(0, 0, 0); wheelsSize = new Size(98, 98); wheels = new Oval(pictureLocation, wheelsOffset, wheelsSize, wheelsColor);
if(appletThread == null) { appletThread = new Thread(this); appletThread.start(); } } public void start() { }
public void stop() { } public void destroy() {
if(appletThread != null){ appletThread.stop(); appletThread = null; } } public void run(){ int Y = 20; boolean move_down=true; int Vertical_Count=0; while(true) { //Sample code for movement if(Vertical_Count == 200) move_down = false; if(vertical_Count == 0) move_down = true; if(move_right) { Y+=1; //Y++; Y=Y+1 Vertical_Count++; } else{ Y-=1; //Y--; Y=Y-1 Vertical_Count--; } pictureLocation = new Location(X, Y); oval = new Oval(pictureLocation, ovalOffset, size, color); oval2 = new Oval(pictureLocation, ovalOffset2, size2, color2); neck = new Box(pictureLocation, neckOffset, neckSize, neckColor); eye = new Oval(pictureLocation, eyeOffset, eyeSize, eyeColor); eyes = new Oval(pictureLocation, eyesOffset, eyesSize, eyesColor); repaint(); try{Thread.sleep(100);} catch(InterruptedException e){System.exit(1);}
/* Paint an oval */ public void paint(Graphics g) { ERROR LINE oval.paint(g); oval2.paint(g); neck.paint(g); bot.paint(g); eye.paint(g); eyes.paint(g); wheel.paint(g); wheels.paint(g); } ;} } }
|
|
|
|
|
|
|
Re: Java assignment help
Posted:
Nov 10, 2008 6:27 AM
in response to: blazinginferno
|
|
|
You are missing the "end curly brace" for the run() method preceding your paint() method.
|
|
|
|
|
|
|
|
Re: Java assignment help
Posted:
Nov 10, 2008 7:29 AM
in response to: blazinginferno
|
|
|
Blizinginferno has your answer for you, you might also just wanna get a good IDE (Both Eclipse and NetBeans would do for you). They can help you spot syntactic issues on the fly, and with the right plugins, can help you make your code very clean and maintainable.
|
|
|
|
|
|
|
|
Re: Java assignment help
Posted:
Nov 10, 2008 11:27 AM
in response to: blazinginferno
|
|
|
download and use Netbeans. I also think a student should make time to read books.
|
|
|
|
|
|
|
|
Re: Java assignment help
Posted:
Nov 10, 2008 1:39 PM
in response to: blazinginferno
|
|
|
This is the JavaHelp API forum, not the general Java help forum.
|
|
|
|
|
|
|
|
Re: Java assignment help
Posted:
Nov 11, 2008 1:31 AM
in response to: blazinginferno
|
|
|
Go read a book.
Hopefully this is a required class and you aren't a comp sci major. If you are, pick another career field. If you don't like reading about programming, programming is definitely a career to avoid.
|
|
|
|
|
|
|
|
Re: Java assignment help
Posted:
Nov 23, 2008 2:29 PM
in response to: blazinginferno
|
|
|
you can get a service from www.assignmenthelp.net , they are very good at java.
|
|
|
|
|