Results 1 to 13 of 13
  1. #1
    w4ssup's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    1,500
    Reputation
    10
    Thanks
    383

    java help (codecademy tut)...

    so im learning java on codecademy and im on Compare Function part 2. what if choice 1 is rock... (i already ask for help but no one reply for shit...)

    info given:
    Code:
    You're doing great! Now we consider the other scenarios. Let's break the problem down a little. What if choice1 is "rock"? Given choice1 is "rock",
    
    a. if choice2 is "scissors", then "rock" wins.
    b. if choice2 is "paper", then "paper" wins.
    
    How do we structure this? It's a bit different to what we have already seen. We will first have an if statement. And then the code inside that if statement will be...another if statement!
    
    Under the existing code in the function compare, write an if statement where the condition is choice1 equals "rock".
    In the code block for the if statement, write an if / else statement. In that statement, if choice2 is "scissors", return "rock wins". Otherwise, return "paper wins".
    hint given:
    Code:
    This putting if statements inside if statements is a little tricky at first. Below is an outline of what the syntax should look like:
    
    if (condition) {
         if (condition) {
             return "some string";
         } else {
             return "some other string";
    }


    my code:
    Code:
    var compare = function(choice1, choice2)
    {
    	if (choice1 === choice2);
    {
    	return "The result is a tie!";
    } if (choice1 === "rock"):
    {
         if (choice2 === "scissors") {
             return "rock wins";
         } else {
             return "paper wins";
         }
    } function(compare)
    };

    error: Did you define a function called compare?


    what i do wrong? >:I been stuck on this shit for 3 days -.-

  2. #2
    Ameer's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Location
    MPGH
    Posts
    14,669
    Reputation
    2353
    Thanks
    6,358
    you must define compare first -_-

    League of Legends Minion - 08/25/16


  3. #3
    w4ssup's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    1,500
    Reputation
    10
    Thanks
    383
    Quote Originally Posted by Arabian View Post
    you must define compare first -_-
    i tried function(compare) but it didnt work.. or did i do it wrong

    and i did function compare() still didnt work... and where am i suppose to put it? (still newish to java)
    Last edited by w4ssup; 03-01-2013 at 03:36 PM.

  4. #4
    ☬Ξητσρζ Ζσ♍βε δτσηε☬
    Former Staff
    Premium Member
    Lehsyrus's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Jersey
    Posts
    10,900
    Reputation
    1281
    Thanks
    3,071
    A function is called a method in Java. You have to declare the method first.

    I'm surprised code academy didn't cover this.

  5. #5
    w4ssup's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    1,500
    Reputation
    10
    Thanks
    383
    Quote Originally Posted by Lehsyrus View Post
    A function is called a method in Java. You have to declare the method first.

    I'm surprised code academy didn't cover this.
    i did didnt i? and i ask my coder friend and he cant find out how to pass this stage either :I can you tell me wat im suppose to type?

  6. #6
    ☬Ξητσρζ Ζσ♍βε δτσηε☬
    Former Staff
    Premium Member
    Lehsyrus's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Jersey
    Posts
    10,900
    Reputation
    1281
    Thanks
    3,071
    Well the way you are being taught in general is wrong. It isn't showing any of the proper syntax.

    I won't give you the answer, instead here is a good tutorial that shows how the syntax will generally need to be formatted.

    https://www.tutorialspoint.com/java/java_tutorial.pdf

  7. The Following User Says Thank You to Lehsyrus For This Useful Post:

    666HiddenMaster666 (03-02-2013)

  8. #7
    w4ssup's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    1,500
    Reputation
    10
    Thanks
    383
    Quote Originally Posted by Lehsyrus View Post
    Well the way you are being taught in general is wrong. It isn't showing any of the proper syntax.

    I won't give you the answer, instead here is a good tutorial that shows how the syntax will generally need to be formatted.

    https://www.tutorialspoint.com/java/java_tutorial.pdf
    idk which part am i suppose to look at

  9. #8
    ☬Ξητσρζ Ζσ♍βε δτσηε☬
    Former Staff
    Premium Member
    Lehsyrus's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Jersey
    Posts
    10,900
    Reputation
    1281
    Thanks
    3,071
    All of it. Just trust me that document will do you better than codeacademy.

  10. #9
    w4ssup's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    1,500
    Reputation
    10
    Thanks
    383
    Quote Originally Posted by Lehsyrus View Post
    All of it. Just trust me that document will do you better than codeacademy.
    lol i hate reading but ill read it

  11. #10
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    607
    My Mood
    Happy
    Jesus christ. Programming section.

  12. #11
    w4ssup's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    1,500
    Reputation
    10
    Thanks
    383
    Quote Originally Posted by Virtual Void View Post
    Jesus christ. Programming section.
    nah.. it dont get enough views there for help

  13. #12
    master131's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    8,855
    Reputation
    3438
    Thanks
    81,042
    My Mood
    Breezy
    Codecademy teaches JavaScript, not Java. Get it right, they're 2 different things.

    Under the existing code
    What the fuck did you do the existing code.
    Donate:
    BTC: 1GEny3y5tsYfw8E8A45upK6PKVAEcUDNv9


    Handy Tools/Hacks:
    Extreme Injector v3.7.1 *NEW*
    A powerful and advanced injector in a simple GUI.
    Can scramble DLLs on injection making them harder to detect and even make detected hacks work again!

    Minion Since: 13th January 2011
    Moderator Since: 6th May 2011
    Global Moderator Since: 29th April 2012
    Super User/Unknown Since: 23rd July 2013
    'Game Hacking' Team Since: 30th July 2013

    --My Art--
    [Roxas - Pixel Art, WIP]
    [Natsu - Drawn]
    [Natsu - Coloured]


    All drawings are coloured using Photoshop.

    --Gifts--
    [Kyle]

  14. #13
    w4ssup's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    1,500
    Reputation
    10
    Thanks
    383
    Quote Originally Posted by master131 View Post
    Codecademy teaches JavaScript, not Java. Get it right, they're 2 different things.



    What the fuck did you do the existing code.

    this
    if (choice1 === "rock"):
    {
    if (choice2 === "scissors") {
    return "rock wins";
    } else {
    return "paper wins";
    }
    } function(compare)
    };

Similar Threads

  1. [Help Request] Heya java help
    By molina174 in forum Minecraft Help
    Replies: 3
    Last Post: 05-09-2011, 10:48 PM
  2. -HELPFUL-c++ tuts!!!
    By hotfudge2100 in forum C++/C Programming
    Replies: 4
    Last Post: 12-09-2008, 09:07 PM
  3. helpful c++ tuts!
    By hotfudge2100 in forum C++/C Programming
    Replies: 4
    Last Post: 10-15-2008, 04:00 PM
  4. Help on TUT
    By Staunton in forum Combat Arms Hacks & Cheats
    Replies: 0
    Last Post: 08-03-2008, 05:18 AM
  5. [HELP ME] Tuts/Adresses
    By sidnietje in forum WarRock - International Hacks
    Replies: 1
    Last Post: 10-29-2007, 03:35 PM