Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 44
  1. #21
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    Ok, but I did it, and this is what came out:
    Java Code:
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 0
    Value 1: 0
    Value 2: 5
    Value 1: 5
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 2: 1
    Value 1: 1
    Value 3: 1
    Value 3: 1
    Value 1 = Map reader
    Value 2 = Block Constructor
    Value 3 = Block draw void

    Apparently it is the map reader, what's wrong with that then?

  2. #22
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    Where does id have a value that is the problem?
    Value 1 = Map reader
    Value 2 = Block Constructor
    Value 3 = Block draw void
    Which label(s) is for where id is given a value in an assignment statement?
    Which label(s) is for where the content of id is used but not changed?
    If you don't understand my response, don't ignore it, ask a question.

  3. #23
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    it's not that problem anymore, I don't think, it's not reading the maps correctly. Value 1 is where the value is sent to the Block class from the map file. Value 2 is in the block constructor, where it becomes the value of the Block's id. And Value 3 is what the draw method sees as the block's id. But now, it looks like the map file is being read incorrectly, it's returning 0 from the map file, even though there are 5s and 1s and 0s, so, I have no idea.
    Last edited by cjburkey01; 06-14-2014 at 02:59 PM. Reason: Missed important info

  4. #24
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    it's returning 0 from the map file,
    Time for more debugging. Add some println statements to print the values of the variables when the lines from the map file are read to see if they are read and handled correctly.
    The Arrays class's toString() method is useful for printing arrays like that returned by split()
    Java Code:
    System.out.println("an ID "+ java.util.Arrays.toString(theArrayName));
    If you don't understand my response, don't ignore it, ask a question.

  5. #25
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    Post#13 shows the file's contents. How do the values in post#21 match against the what is in the file?
    They look very similar to me.
    If you don't understand my response, don't ignore it, ask a question.

  6. #26
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    Java Code:
    Level 1 - It's easy
    15
    2
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 5
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    That's what it reads from

  7. #27
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    Yes, that was shown in post#13.

    looks like the map file is being read incorrectly,
    What is the problem now?
    If you don't understand my response, don't ignore it, ask a question.

  8. #28
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    it's the same, I'll do that print method you said.

  9. #29
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    UPDATE: It does read the file right...
    Java Code:
    an ID [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]
    an ID [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    WHERE IS THIS MESSING UP D': D': D':

  10. #30
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    Looks good to me. Where is the problem?
    If you don't understand my response, don't ignore it, ask a question.

  11. #31
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    The block class still recieves 0 for everything, and that makes the level look like a block, not a line with a flag. somewhere the id is not sent

  12. #32
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    The block class still recieves 0 for everything
    How is that? The print out in post#21 shows that the Block class's constructor got all the values (Value 2:) from the file.
    If you don't understand my response, don't ignore it, ask a question.

  13. #33
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    It's only getting the same value, it should be getting a few 1's, a few 0s, and a 5. It's only getting 1/0

  14. #34
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    Can you post some print out that shows that?
    Post#21 shows that the Block class's constructor is getting all of the values from the file.
    If you don't understand my response, don't ignore it, ask a question.

  15. #35
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    It's only getting 0, which means 1 to this thing

  16. #36
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    It's only getting 0, which means 1 to this thing
    Not sure what that means. Is its value a 0 or a 1?

    Here's a test: Change the data in the last line of the file to:
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 4
    and see what happens.
    Does it now get a 3?

    Then change it to:
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 2
    Does it now get a 1?
    If you don't understand my response, don't ignore it, ask a question.

  17. #37
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    OK, I tried it with a block that has a different shape, and it looks like it does receive it, but it still has the samr texture.

  18. #38
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    What about the 1 vs 0 numbers that you were complaining about? I was trying to see what the value of id would be for those two different values in the input file would be.
    If you don't understand my response, don't ignore it, ask a question.

  19. #39
    cjburkey01 is offline Member
    Join Date
    Dec 2013
    Posts
    70
    Rep Power
    0

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    I'm not complaining about that. I'll just rewatch the tutorial in which I got this mechanism from, and rewrite it.

  20. #40
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: Variable Is Set, Works, But Then In Void, Returns 0

    Did you try the code with the input file I suggested?
    What did the debug print out show? See post#21 for what the print out should look like.
    If you don't understand my response, don't ignore it, ask a question.

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 18
    Last Post: 03-26-2014, 11:43 PM
  2. Please explain static void and void methods are ?
    By shavindra in forum New To Java
    Replies: 5
    Last Post: 01-10-2013, 09:46 PM
  3. accessing variables in a method that returns a void
    By mochajava in forum New To Java
    Replies: 2
    Last Post: 02-12-2011, 09:00 PM
  4. Replies: 5
    Last Post: 01-25-2008, 12:53 AM

Tags for this Thread

Posting Permissions

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