Skip to content

Stage 0: Methods and Mutable State - #301

Open
httphypixelnet wants to merge 2 commits into
frcsoftware:mainfrom
httphypixelnet:methods
Open

httphypixelnet wants to merge 2 commits into
frcsoftware:mainfrom
httphypixelnet:methods

Conversation

@httphypixelnet

Copy link
Copy Markdown
Contributor

Description

Added source files for using methods and interacting with mutable state in Java

Meta

Closes #287

Merge checklist:

@github-actions

Copy link
Copy Markdown

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

@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.

A few formatting/writing inconsistencies, but otherwise looks good to me

ScoreKeeper blueAlliance = new ScoreKeeper(30);

// Print the result of `redAlliance.hasWon(blueAlliance.getScore())`.
// Since redAlliance's score is currently 0, this should print `false`.

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
// Since redAlliance's score is currently 0, this should print `false`.
// Since `redAlliance`'s score is currently 0, this should print `false`.


// Print the result of `redAlliance.hasWon(blueAlliance.getScore())`.
// Since redAlliance's score is currently 0, this should print `false`.
// After running, change blueAlliance's starting score to `-5`; the code

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
// After running, change blueAlliance's starting score to `-5`; the code
// After running, change `blueAlliance`'s starting score to `-5`; the code

System.out.println(redAlliance.hasWon(blueAlliance.getScore()));

// Call `redAlliance.reset()`, then print `redAlliance.getScore()` again.
// It should now print `0`, even though redAlliance never had any

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
// It should now print `0`, even though redAlliance never had any
// It should now print `0`, even though `redAlliance` never had any



// Print the result of `redAlliance.hasWon(blueAlliance.getScore())`.
// Since redAlliance's score is currently 0, this should print `false`.

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
// Since redAlliance's score is currently 0, this should print `false`.
// Since `redAlliance`'s score is currently 0, this should print `false`.


// Print the result of `redAlliance.hasWon(blueAlliance.getScore())`.
// Since redAlliance's score is currently 0, this should print `false`.
// After running, change blueAlliance's starting score to `-5`; the code

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
// After running, change blueAlliance's starting score to `-5`; the code
// After running, change `blueAlliance`'s starting score to `-5`; the code

// `System.out.println(redAlliance.getScore());`
System.out.println(redAlliance.getScore());

// Call `redAlliance.applyPenalty(20)`. Since 56 - 20 = 36 is still at

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
// Call `redAlliance.applyPenalty(20)`. Since 56 - 20 = 36 is still at
// Call `redAlliance.applyPenalty(20)`. Since 56 - 20 equals 36, it is still above

System.out.println(redAlliance.getScore());

// Call `redAlliance.applyPenalty(20)`. Since 56 - 20 = 36 is still at
// least `MIN_SCORE`, this should print "Penalty applied. Score is now: 36".

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
// least `MIN_SCORE`, this should print "Penalty applied. Score is now: 36".
// or equal to `MIN_SCORE`, this should print "Penalty applied. Score is now: 36".


void main() {
// Create a ScoreKeeper named `redAlliance` using the no-argument
// constructor. Its score should start at 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
// constructor. Its score should start at 0.
// constructor. Its score should start at `0`.

// `System.out.println(redAlliance.getScore());`


// Call `redAlliance.applyPenalty(20)`. Since 56 - 20 = 36 is still at

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
// Call `redAlliance.applyPenalty(20)`. Since 56 - 20 = 36 is still at
// Call `redAlliance.applyPenalty(20)`. Since 56 - 20 equals 36, it is still above



// Call `redAlliance.applyPenalty(20)`. Since 56 - 20 = 36 is still at
// least `MIN_SCORE`, this should print "Penalty applied. Score is now: 36".

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
// least `MIN_SCORE`, this should print "Penalty applied. Score is now: 36".
// or equal to `MIN_SCORE`, this should print "Penalty applied. Score is now: 36".

@EdanThomton EdanThomton added this to the First Publish milestone Sep 18, 2026
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: Methods and Mutable State

2 participants