Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Basic java problem

    Hey

    Having problem with this code and i have no idea why!!

    public class Delivery
    {

    private int refno;
    private int cost;
    private Time deliveryin;
    private Time delivered;
    private String Name;

    public Delivery(int ref, int cost, int hour, int min, String Name)
    {
    refno = ref;
    cost = cost;
    deliveryin = new Time(hour, min);
    delivered = null;
    Name = Name;
    }



    }

  • #2
    Gox
    Gox is offline
    Regular Coder Gox's Avatar
    Join Date
    May 2006
    Location
    Ontario, Canada
    Posts
    392
    Thanks
    2
    Thanked 20 Times in 20 Posts
    What sort of problem are you having? Does it compile? If not what's the error and line number the compiler gives? If it does compile, what errors do you see at runtime? Does it not produce the correct results or does it crash?

    Providing this information will make it easier for people to help you.

  • #3
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Gox View Post
    What sort of problem are you having? Does it compile? If not what's the error and line number the compiler gives? If it does compile, what errors do you see at runtime? Does it not produce the correct results or does it crash?

    Providing this information will make it easier for people to help you.
    When inputting data into the string field i get "Error cannot find symbol - variable" only happens with the string field. Im baffled code seems fine!

  • #4
    Gox
    Gox is offline
    Regular Coder Gox's Avatar
    Join Date
    May 2006
    Location
    Ontario, Canada
    Posts
    392
    Thanks
    2
    Thanked 20 Times in 20 Posts
    Does changing the name assignment to
    this.Name = Name; help?

  • #5
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Gox View Post
    Does changing the name assignment to
    this.Name = Name; help?
    Tried it, but nope, same error message. Thanks anyway

  • #6
    Gox
    Gox is offline
    Regular Coder Gox's Avatar
    Join Date
    May 2006
    Location
    Ontario, Canada
    Posts
    392
    Thanks
    2
    Thanked 20 Times in 20 Posts
    The compiler should report the line of code associated with the error. Take a look at that and hopefully it will at least narrow down where the error is.

    EDIT: Are you missing an import for the Time class or is this a class you wrote yourself? The only errors I get from the code you posted is because it can't find the class Time. Again, if you wrote this class you may not get this error. This leads me to believe that the error you're looking for is not in the code you posted.
    Last edited by Gox; 12-12-2008 at 02:00 AM.

  • #7
    New Coder
    Join Date
    Nov 2008
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could you tell me what sort of problem you are facing? Is it compile time error or run time error? Paste the error information so that I can look into
    the same.

  • #8
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Starnge this is, creating new class like this still doesnt work. Same error message, i can compile the class but when i input something into the string i get "Error cannot find symbol - variable andy".

    public class New
    {

    private String Name;

    public New(String Name)
    {
    this.Name = Name;
    }



    }
    Even that doesnt work :S:S

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    can you show us (in code) how you use this class? My guess is that you don't call the constructor in a correct way
    I am the luckiest man in the world

  • #10
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Roelf View Post
    can you show us (in code) how you use this class? My guess is that you don't call the constructor in a correct way
    Compile it using blue j, go out, new distance then type in parameters, hit ok and then I get that error message. Thanks for the help!

  • #11
    Gox
    Gox is offline
    Regular Coder Gox's Avatar
    Join Date
    May 2006
    Location
    Ontario, Canada
    Posts
    392
    Thanks
    2
    Thanked 20 Times in 20 Posts
    Please provide the exact code that produces the "Cannot find symbol andy" error. There is nothing in the code you provided that should produce such an error.

    Or provide more complete steps you used in blue j. I've heard of blue j but have never used it so the instructions you gave are hard to follow. Especially this part "...go out, new distance then type in parameters". What do you mean by "go out"? What is "new distance"? Where are you typing in parameters?
    Last edited by Gox; 12-12-2008 at 11:14 PM.

  • #12
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have fixed the problem, was a completely stupid mistake, was using earlier version of BlueJ which doesnt require you to type string in "x" whereas this version you do. Sorry for time wasting, was my mistake.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •