Skip to content

Conversation

kahgoh
Copy link
Member

@kahgoh kahgoh commented Aug 31, 2025

This ports the cars assemble from the Go track. The reason for going with the Go version instead of Java is that the Java version uses if statements in the same exercise, which I thought could be a separate concept.

This is a draft as it still missing an introduction (I plan on doing writing an introduction based on the concept introduction before taking this out of draft).

@colinleach
Copy link
Contributor

colinleach commented Aug 31, 2025

My recommendation is:

  • Copy the intro from the concept.
  • Delete everything not needed by the exercise.
  • Warn me if there is extra content you need to add, so I can include this in the concept docs.

If you hate my version and want a total rewrite, that is a separate problem we will need to address!

Also: I made some recent changes to PR #711 to address review comments, so it may be worth waiting until that is merged.

"colinleach"
],
"contributors": [],
"blurb": "Kotlin has a variety of integer and floating point types, and a math library to manipulate them."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"blurb": "Kotlin has a variety of integer and floating point types, and a math library to manipulate them."
"blurb": "Kotlin has a variety of integer and floating point types, and a math library to manipulate them."

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll make changes in PR #711 (I can't edit this PR)

Assigning larger values will cause ["overflow"][wiki-overflow], causing either an exception (_bad_) or corrupted data (_worse_).

- Integers can be `Byte`, `Short`, `Int` or `Long`, respectively 8, 16, 32 and 64 bits (1, 2 4, 8 bytes).
- Unsigned integers have a `U` prefix: `UByte`, `UShort`, `UInt` or `ULong`.
Copy link
Member

Choose a reason for hiding this comment

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

We should explain signed versus unsigned at some point before this.

Copy link
Contributor

Choose a reason for hiding this comment

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

There isn't much "before", so I tried to clarify these bullets.

Copy link
Member

Choose a reason for hiding this comment

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

I am now reviewing this and I saw that is a suggestion I already made on the concept doc.

- Unsigned integers have a `U` prefix: `UByte`, `UShort`, `UInt` or `ULong`.
- Floating point types are `Float` (32-bit) or `Double` (64-bit).

Integer variables relying on type inference default to `Int`, even on 64-bit machines, but floating point variables default to `Double`.
Copy link
Member

Choose a reason for hiding this comment

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

Would students be expected to know what type inference is by this point?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it was in Basics

val lightSpeed = 3.0e8 // scientific notation (units of m/s)
```

Hexadecimal and binary literals are conventional: `0x7F` and `0b100101` respectively.
Copy link
Member

@BNAndras BNAndras Aug 31, 2025

Choose a reason for hiding this comment

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

conventional relative to what? What makes them a hexadecimal or binary literal specifically?

Copy link
Member

Choose a reason for hiding this comment

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

I am now reviewing this and I saw that is a suggestion I already made on the concept doc.

}

@Test
fun `calculate working cars per minute with 0 production rate`() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fun `calculate working cars per minute with 0 production rate`() {
fun `calculate working cars per minute with 0 success rate`() {

colinleach added a commit to colinleach/kotlin that referenced this pull request Aug 31, 2025
@kahgoh kahgoh mentioned this pull request Sep 1, 2025
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