Code Theory

Do you think this is practical? The idea is to save time.

void HeightDown();
{
i–;
if(i < 3 && i >= 0)
{
if(i == 1)
{
LLift.rotateTo(300, rotationUnits::deg);
}
else if(i == 2)
{
LLift.rotateTo(600, rotationUnits::deg);
}
else if(i == 0)
{
LLift.rotateTo(30, rotationUnits::deg);
}
}
else
{
i++;
}

}
void HeightUp();
{
i++;

if(i < 3 && i >= 0)
{
   if(i == 1)
    {
     LLift.rotateTo(300, rotationUnits::deg);
    } 
    else if(i == 2)
    {
    LLift.rotateTo(600, rotationUnits::deg);
    }
    else if(i == 0)
    {
    LLift.rotateTo(30, rotationUnits::deg);
    }
}
else
{
  i--;
}

Is the goal of this code to move a lift up and down? Also what do you mean by the idea is to save time?

PS: next time please put all your code into a code block by using 3 ` at the start and end of the code.

1 Like

Huh. Not bad. I don’t think it would save time, but I like the conservation of buttons so that it has multiple levels, but you only need two buttons to navigate. So yes should be practical, I might try it myself, no it probably wouldn’t save any time.

1 Like

Just as a heads-up for next time, I am fairly lucky I was able to read through the code and understand (I hope) what you are trying to do. So if you have pretty much any problem in the future and you want to ask the forum, please state what you are trying to do. Also, you could compact the code significantly by using switch statements. See here.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.