Skip to content

Stage 0: Conditionals#40

Open
Adrianamm wants to merge 9 commits into
frcsoftware:mainfrom
Adrianamm:Conditional
Open

Stage 0: Conditionals#40
Adrianamm wants to merge 9 commits into
frcsoftware:mainfrom
Adrianamm:Conditional

Conversation

@Adrianamm

Copy link
Copy Markdown
Member

Added page about conditional statements
This includes: If, else if, else. Switch isn't included for now as discussed on Discord
Exercises will be added in later as it's being covered by #32

@CodeMyGame1 CodeMyGame1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly good, just left comments on formatting and grammar. My apologies for the nitpicking 😭

Comment thread public/conditionals/elseif.png
Comment thread src/content/docs/intro-to-java/conditionals.mdx Outdated
Comment thread src/content/docs/intro-to-java/conditionals.mdx Outdated
Comment thread src/content/docs/intro-to-java/conditionals.mdx Outdated
Comment thread src/content/docs/intro-to-java/conditionals.mdx Outdated
Comment thread src/content/docs/intro-to-java/conditionals.mdx Outdated
Comment thread src/content/docs/intro-to-java/conditionals.mdx Outdated
Comment thread src/content/docs/intro-to-java/conditionals.mdx Outdated
Comment thread src/content/docs/intro-to-java/conditionals.mdx Outdated
Comment thread src/content/docs/intro-to-java/conditionals.mdx Outdated
@samfreund samfreund force-pushed the main branch 7 times, most recently from 813ea0d to 7043aa5 Compare June 25, 2026 05:22
@github-actions

Copy link
Copy Markdown

🌐 Preview URL: https://pr-40.frcsoftware.pages.dev

@samfreund samfreund closed this Jun 25, 2026
@samfreund samfreund reopened this Jun 25, 2026
@samfreund samfreund force-pushed the main branch 2 times, most recently from b5680fd to 6ca05c8 Compare June 25, 2026 06:58
@samfreund samfreund closed this Jun 25, 2026
@samfreund samfreund reopened this Jun 25, 2026
@samfreund samfreund force-pushed the main branch 7 times, most recently from ea813ca to f514f00 Compare June 30, 2026 04:58
In everyday life, we make decisions based on different situations.
Such as "If we are hungry, then we get a snack" or "If we are tired, we go to bed".
Often in code, we want our program to do something similar and make different decisions based on different situations.
For robots, this could be Often in code, we want our program to do something similar and make different decisions based on different situations.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence reads weirdly, Often should be lowercase too

As a reminder, a keyword is a reserved word that the compiler uses to run the code.
In Java, we use the following keywords for conditionals: if, else, and else if

## If

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should match same capitalization as other section titles (else if and else both being lowercase)

Our example code has the robot drive at full speed if the distance is greater than 10cm, has the robot drive at half speed if the distance is less than 10cm, but the robot never stops if it reaches its target distance.
You could add another else if, or you could add an else conditional.

## else

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably put else above else if? Even though in an actual if statement they're in this order, covering the concept of else before extending it to else if makes more sense I think

Let's break down what this new addition means.
else if is a keyword that allows the conditional to run a different task if the if statement is false.

If `Condition_A` is true then the code inside the if statement will run.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar note to the other PR, but these variables should all be lowercased and follow normal naming convention (also requires changing the code examples)

```

else statements do not have parentheses because they do not have a condition.
If Condition is true, then the code inside the if statement will run.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Condition here should be lowercase to match the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants