d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Karen...
Add Reply New Topic New Poll
Member
Posts: 13,042
Joined: Apr 12 2008
Gold: 0.00
Aug 25 2014 09:25pm
Okay, so I'm just helping my brother out with this stupid exercises, and I haven't taken C++ yet, so I'm not 100% familiar with why this is giving me a script error on CodeHS

The basic idea:
When there is a hurdle, go around it, when there isn't, just simply move forward until you reach the end.

Why is the following throwing a script error?

function start()
{
for (int i = 0; i < 13; i++)
{
if(frontIsClear())
{
move();
}

else
{
jumpHurdle();
}
}
}

function jumpHurdle()
{
turnLeft();
move();
turnRight();
move();
turnRight();
move();
turnLeft();
}

sorry this is karol or whatever, the dog lol

This post was edited by DD_Rocking on Aug 25 2014 09:26pm
Member
Posts: 13,042
Joined: Apr 12 2008
Gold: 0.00
Aug 25 2014 09:35pm
nevermind, i didn't know it uses the term "var" instead of the variable type like it does in Java... Doesn't make much sense to me but I guess most for loops are assumed to be integers?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 25 2014 09:35pm
in c++, you don't use a "function" keyword to define methods.
Member
Posts: 13,042
Joined: Apr 12 2008
Gold: 0.00
Aug 25 2014 09:41pm
Quote (carteblanche @ Aug 25 2014 10:35pm)
in c++, you don't use a "function" keyword to define methods.


well, this is probably specific to karel the dog bull crap then lol, thanks
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 25 2014 09:48pm
Quote (DD_Rocking @ Aug 25 2014 11:41pm)
well, this is probably specific to karel the dog bull crap then lol, thanks


you seem to assume we all know what karel is. i briefly glanced at codehs and it doesn't give us any details unless we pay for it. it doesn't even tell me what language it's in. i'm under the impression it's not c++ at all, but rather some made up language.

i'm checking wiki and codehs was founded in 2012. none of us were in high school back then, so i doubt any of us ever used it lol

This post was edited by carteblanche on Aug 25 2014 09:54pm
Member
Posts: 13,042
Joined: Apr 12 2008
Gold: 0.00
Aug 25 2014 10:34pm
Quote (carteblanche @ Aug 25 2014 10:48pm)
you seem to assume we all know what karel is. i briefly glanced at codehs and it doesn't give us any details unless we pay for it. it doesn't even tell me what language it's in. i'm under the impression it's not c++ at all, but rather some made up language.

i'm checking wiki and codehs was founded in 2012. none of us were in high school back then, so i doubt any of us ever used it lol


its a principles of programming class he's taking, so maybe some people in college now may know what it is, though I think you are absolutely correct about it being some made up language
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll