Skip to content

Stage 0: Loops Exercises - #295

Open
Adrianamm wants to merge 9 commits into
frcsoftware:mainfrom
Adrianamm:loops-excerises
Open

Adrianamm wants to merge 9 commits into
frcsoftware:mainfrom
Adrianamm:loops-excerises

Conversation

@Adrianamm

@Adrianamm Adrianamm commented Sep 16, 2026

Copy link
Copy Markdown
Member

Description

What changed?
Why? (the code + comments should speak for itself on the "how")
Exercises.

Any issues this pull request closes or pull requests this supersedes should be linked with Closes #289 .

Meta

Merge checklist:

@github-actions

Copy link
Copy Markdown

🌐 Preview URL: https://pr-295-frcsoftware.frcsoftware.workers.dev

@Spaceman113138 Spaceman113138 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a bit of inconsistantcy as to if there is a period at the end of a sentance or not.

Comment thread examples/stage0/solutions/src/loops.java Outdated
Comment thread examples/stage0/solutions/src/loops.java Outdated
Comment thread examples/stage0/templates/src/loops.java Outdated
Comment thread examples/stage0/templates/src/loops.java Outdated
Co-authored-by: Spaceman 11 <135277197+Spaceman113138@users.noreply.github.com>
Comment thread examples/stage0/templates/src/loops.java Outdated
Adrianamm and others added 2 commits September 16, 2026 00:32
Co-authored-by: Spaceman 11 <135277197+Spaceman113138@users.noreply.github.com>

@Spaceman113138 Spaceman113138 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

3rd times the charm

Comment thread examples/stage0/solutions/src/loops.java Outdated
Comment thread examples/stage0/solutions/src/loops.java Outdated
Adrianamm and others added 2 commits September 16, 2026 00:37
Co-authored-by: Spaceman 11 <135277197+Spaceman113138@users.noreply.github.com>
Comment thread examples/stage0/templates/src/loops.java Outdated
Comment thread examples/stage0/solutions/src/loops.java Outdated
Co-authored-by: Sam Freund <samf.236@proton.me>
for (int timer = 15; timer >= 0; timer--){
if (timer <= 0 ){
drivetrain.setThrottle(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this extra line the result of spotless/prettify or is it accidental?

@EdanThomton EdanThomton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's some inconsistent formatting of variable names in the comments, but other than that it looks good to me!


// First, create a for loop that has a new integer variable named
// `timer` that is set to 15. The for loop checks if `timer` is
// greater than or equal to 0 then it decreases timer by one

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// greater than or equal to 0 then it decreases timer by one
// greater than or equal to 0, then it decreases `timer` by one


// First, create a for loop that has a new integer variable named
// `timer` that is set to 15. The for loop checks if `timer` is
// greater than or equal to 0 then it decreases timer by one

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// greater than or equal to 0 then it decreases timer by one
// greater than or equal to 0, then it decreases `timer` by one


// Create a for loop that has a new integer variable named `timer`
// that is set to 15. Check for when timer is greater than or equal to 0,
// then decrease timer by one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// then decrease timer by one.
// then decrease `timer` by one.

System.out.println("but yours did");

// Create a for loop that has a new integer variable named `timer`
// that is set to 15. Check for when timer is greater than or equal to 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// that is set to 15. Check for when timer is greater than or equal to 0,
// that is set to 15. Check for when `timer` is greater than or equal to 0,

void main() {

// First, create a new integer variable named `error`
// Below, create a while loop that compares if error is less than 5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Below, create a while loop that compares if error is less than 5
// Below, create a while loop that checks if `error` is less than 5

// First, create a new integer variable named `error`
// Below, create a while loop that compares if error is less than 5
// if that is true, print "Robots should not quit", then increase `error` by one
// if error is no longer less than 5, print "but yours did"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// if error is no longer less than 5, print "but yours did"
// when `error` is no longer less than 5, print "but yours did"



// Create a for loop that has a new integer variable named `timer`
// that is set to 15. Check for when timer is greater than or equal to 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// that is set to 15. Check for when timer is greater than or equal to 0,
// that is set to 15. Check for when `timer` is greater than or equal to 0,


// Create a for loop that has a new integer variable named `timer`
// that is set to 15. Check for when timer is greater than or equal to 0,
// then decrease timer by one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// then decrease timer by one.
// then decrease `timer` by one.

// First, create a for loop that has a new integer variable named
// `timer` that is set to 15. The for loop checks if `timer` is
// greater than or equal to 0 then it decreases timer by one
// Inside the for loop, have an if statement that checks if timer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Inside the for loop, have an if statement that checks if timer
// Inside the for loop, have an if statement that checks if `timer`

// greater than or equal to 0 then it decreases timer by one
// Inside the for loop, have an if statement that checks if timer
// is less than or equal to 0. If so, set the drivetrain speed to 0
// If the timer is less than or equal to 15, set the speed to one

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// If the timer is less than or equal to 15, set the speed to one
// If the `timer` is less than or equal to 15, set the speed to one

@EdanThomton EdanThomton added this to the First Publish milestone Sep 18, 2026

class Drivetrain {
/**
* Dummy function that spins drivetrain motors at the specified speed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Dummy function that spins drivetrain motors at the specified speed.
* Mock function to simulate running drivetrain motors at specified throttle

It's probably best to use throttle as the variable name

Comment on lines +22 to +23
// if that is true, print "Robots should not quit", then increase `error` by one
// if error is no longer less than 5, print "but yours did"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This example is funny to us, but might be confusing and not very intuitive what the students should be trying to accomplish with this loop. What if we made a more realistic scenario like:

A robot gyro must be calibrated before using it. Calibrating is done by printing "Calibrating..." to the console 5 times. Using a while loop and an integer, calibrate the gyro, then print "Calibration successful"

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stage 0: Loops exercise

5 participants