Current location: Hot Scripts Forums » Programming Languages » Everything Java » I have no idea what I'm doing (cannot find symbol)


I have no idea what I'm doing (cannot find symbol)

Reply
  #1 (permalink)  
Old 09-10-07, 05:37 PM
tophat's Avatar
tophat tophat is offline
Newbie Coder
 
Join Date: Dec 2005
Location: Michigan
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Angry I have no idea what I'm doing (cannot find symbol)

I've been in my java class for about 3 days now. My teacher really blows at teaching this class, because she doesn't explain anything at all. She just uses JavaBook and makes us teach ourselves. Anyways, we have to do this assignment where we make it draw a smiley face. At school I'm using textpad to compile this, at home I'm using NetBeans. At school this will compile. At my house it won't. Here is the Face.java file:

Java Code:
  1. import gpdraw.*;
  2.  
  3. public class Face {
  4.  
  5.     private DrawingTool marker;
  6.     private SketchPad poster;
  7.  
  8.     public Face() {
  9.  
  10.         poster = new SketchPad(600, 600);
  11.         marker = new DrawingTool(poster);
  12.  
  13.     }
  14.  
  15.     public void draw() {
  16.  
  17.         marker.down();
  18.  
  19.         marker.forward(200);
  20.         marker.turnRight(90);
  21.         marker.forward(200);
  22.         marker.turnRight(90);
  23.         marker.forward(200);
  24.         marker.turnRight(90);
  25.         marker.forward(200);
  26.  
  27.          /* this isn't done yet. */
  28.  
  29.     }
  30.  
  31. }

And here is Driver.java

Java Code:
  1. public class Driver {
  2.  
  3.     public static void main (String [] args) {
  4.    
  5.         DrawFace erik = new DrawFace();
  6.         erik.draw();
  7.    
  8.     }
  9.  
  10. }

(I have no idea why I had to put 'erik' but my teacher just told me to.....)

[/code]

Here is the error for Face.java:

init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Erik\Face\build\classes
C:\Documents and Settings\Erik\Face\src\face\Driver.java:5: cannot find symbol
symbol : class Face
location: class Driver
Face erik = new Face();
^
C:\Documents and Settings\Erik\Face\src\face\Driver.java:5: cannot find symbol
symbol : class Face
location: class Driver
Face erik = new Face();
^
2 errors
BUILD FAILED (total time: 0 seconds)

--------------------

And here is the error for Driver.java:

init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Erik\Face\build\classes
C:\Documents and Settings\Erik\Face\src\face\Driver.java:5: cannot find symbol
symbol : class Face
location: class Driver
Face erik = new Face();
^
C:\Documents and Settings\Erik\Face\src\face\Driver.java:5: cannot find symbol
symbol : class Face
location: class Driver
Face erik = new Face();
^
2 errors
BUILD FAILED (total time: 0 seconds)

------------------------

I am a complete noob to this crappy programming language so if someone could just help me so i don't fail this class that would be nice
__________________
tophatcomedy.com

Last edited by UnrealEd; 09-11-07 at 04:20 AM. Reason: please use the [highlight=Java] tag when posting Java code
Reply With Quote
  #2 (permalink)  
Old 09-11-07, 04:23 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
You're not importing the Face class in the Driver.java script.

When you use a class in Java, you always have to import it first, otherwise Java can't find the class, and cannot compile it. Give this a try:
Java Code:
  1. import mypackage.Face;
  2.  
  3. public class Driver {
  4.  
  5.     public static void main (String [] args) {
  6.    
  7.         DrawFace erik = new DrawFace();
  8.         erik.draw();
  9.    
  10.     }
  11.  
  12. }
Just replace "mypackage" with the name of your package (or leave empty if you don't have one, and both the Face as the Driver class reside in the same folder)

BTW: I think you have to use Face instead of DrawFace in the Driver class, as the DrawFace class is non-exsitent.

Edit: if you need good tutorials, check out the Sun Tutorial Pages (available online, and for download) at:
http://java.sun.com/docs/books/tutorial/
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks


Last edited by UnrealEd; 09-11-07 at 04:26 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
idea box mrmaxey Script Requests 1 06-30-07 12:44 AM
How to find the total number of subnodes in a tree structure? subhashparayil ASP 2 03-22-06 11:44 AM
Redirection back to a page from form submit DAL Perl 11 03-21-05 02:45 PM
how to find control in placeholder nnet ASP.NET 0 01-13-04 11:44 PM
From idea to inception at zero cost !!! JasonD General Advertisements 0 06-06-03 03:37 PM


All times are GMT -5. The time now is 05:43 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.