Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions FunctionExercise/FunctionExercise.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/testResources" type="java-test-resource" />
</content>
<orderEntry type="jdk" jdkName="openjdk-23" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>
8 changes: 8 additions & 0 deletions FunctionExercise/src/CamelRide.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fun main() {
startCamelRide(10, 5)
startCamelRide(10)
}
fun startCamelRide(time: Int, speed: Int = 5) {
val distance = time * speed
println("Camel Ride: Distance = $distance km, Speed = $speed km/h, Time = $time hours")
}
8 changes: 8 additions & 0 deletions FunctionExercise/src/DesertTemperature.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fun currentTemperature(morningTemperature: Int, afternoonTemperature: Int): Int {
return (morningTemperature + afternoonTemperature) / 2
}

fun main() {
val averageTemp = currentTemperature(25, 40)
println("Average temperature: $averageTemp")
}
14 changes: 14 additions & 0 deletions FunctionExercise/src/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
fun main() {
val name = "Kotlin"
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
// to see how IntelliJ IDEA suggests fixing it.
println("Hello, " + name + "!")

for (i in 1..5) {
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
println("i = $i")
}
}
8 changes: 8 additions & 0 deletions FunctionExercise/src/OasisCounter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fun findOasis(x: Int, y: Int): String {
return "Oasis found at coordinates ($x, $y)"
}

fun main() {
val result = findOasis(10, 20)
println(result)
}
5 changes: 5 additions & 0 deletions FunctionExercise/src/SandstormSurvival.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fun survivalChance(supplies: Int) = supplies * 10

fun main() {
println("Survival Chance: ${survivalChance(8)}")
}
6 changes: 6 additions & 0 deletions FunctionExercise/src/TheDesertGreeting.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fun main () {
greenTraveler()
}
fun greenTraveler () {
println("Welcome to the Desert, Traveler!")
}
8 changes: 8 additions & 0 deletions FunctionExercise/src/TheDuneExploration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fun exploreDune(height: Int, climbRate: Int) {
val time = height.toDouble() / climbRate
println("Time to Climb the Dune: $time hours")
}

fun main() {
exploreDune(climbRate = 3, height = 20)
}