Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Java questions

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java questions

    Hello everyone, so I have a question regarding the problem with my code, to the question I have attached below. Could anyone tell me if anything is wrong? So here is my code;

    [

    would appreciate the feedback.
    Attached Files Attached Files
    Last edited by GalaxySIV; April 13th, 2014 at 10:02 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Java questions

    tell me if anything is wrong
    Please explain why you think there might be anything wrong. Copy the program's output and paste it here with comments about what you think the problem is.

    If you have questions please post them here, not a link.

    One problem I see is that there are lots of for statements the do NOT have {}s to enclose the code in the for block. That will put a bug into the program the first time code is added to any of those for statements.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java questions

    Quote Originally Posted by Norm View Post
    Please explain why you think there might be anything wrong. Copy the program's output and paste it here with comments about what you think the problem is.

    If you have questions please post them here, not a link.

    One problem I see is that there are lots of for statements the do NOT have {}s to enclose the code in the for block. That will put a bug into the program the first time code is added to any of those for statements.
    To me it seems logically correct, it does not seem to give a compilation error even when i run it on something. It does look messy, however I dont get where in the logic it might be incorrect as no compilation error is given.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Java questions

    Why do you say: tell me if anything is wrong?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java questions

    Because I do not have any reference paper where I can compare my answer with, and also I think there might have been some error in the if (gameLevel == 2) stage, because I feel there are too many conflicting if and nested ifs. Im not entirely sure if it is wrong or correct, which is why I posted to see if more experienced members could highlight the error in my code.

    And you told me that it would put a bug in to my code because of the absence of {}s, so I tried to compile it, and there seems to be no error. However just because there are no compilation errors does not mean there doesn't exist a logic error?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Java questions

    I'm not sure what you are asking. If you don't have any idea if the code is doing what you want or not, what can anyone suggest?

    Make a small, complete program that compiles, executes and shows some error, describe the error and show what you want the program to output.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java questions

    nevermind

Similar Threads

  1. java questions
    By Gwawamo in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 28th, 2014, 04:00 PM
  2. List of my Java3D Questions, and Proguard questions
    By Zachary1234 in forum Java SE APIs
    Replies: 0
    Last Post: November 16th, 2012, 09:40 PM
  3. New to Java some questions
    By unorthadox in forum Java Theory & Questions
    Replies: 3
    Last Post: August 6th, 2012, 09:22 AM
  4. Help in java questions
    By Normal9ja in forum Java Theory & Questions
    Replies: 3
    Last Post: September 21st, 2011, 08:42 PM
  5. Java Questions! :)
    By xs4rdx in forum Java Theory & Questions
    Replies: 0
    Last Post: February 21st, 2010, 08:40 AM