Skip to content

Commit

Permalink
refactor: change the lesson type to lesson
Browse files Browse the repository at this point in the history
  • Loading branch information
GirZ0n committed Nov 9, 2023
1 parent 46e4d1d commit 8c9ce9a
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ class Store {
}
}
}

fun main() {
val store = Store()
println(store.calculateTotalPrice(listOf(1, 2, 3))) // Output: Sum of prices
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,24 @@ custom_name: Inline methods and variables
files:
- name: src/main/kotlin/jetbrains/refactoring/course/inlining/Task.kt
visible: true
placeholders:
- offset: 113
length: 265
placeholder_text: |-
fun calculateTotalPrice(productPrice: List<Int>): Int? {
return try {
val totalPrice = productPrice.sum()
totalPrice
} catch (error: Exception) {
logError(error, "Exception.txt")
null
}
}
private fun logError(error: Exception, filePath: String) {
val file = File(filePath)
val text = error
PrintWriter(file, Charsets.UTF_8).use { it.print(text) }
}
- name: test/Tests.kt
visible: false
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Task 2/2: Inline methods and variables

### Task

In this task, you need to identify unnecessary variables and method and inline them using the automatic Inline
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package jetbrains.refactoring.course.inlining

fun main() {
// Write your solution here
}

This file was deleted.

2 changes: 1 addition & 1 deletion InliningCode/InlineMethodRefactoring/Theory/task-info.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type: theory
custom_name: Inline Method refactoring
files:
- name: src/main/kotlin/jetbrains/refactoring/course/inlining/Task.kt
- name: src/main/kotlin/jetbrains/refactoring/course/inlining/Main.kt
visible: true
2 changes: 2 additions & 0 deletions InliningCode/InlineMethodRefactoring/Theory/task.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Task 1/2: Inline Method refactoring

Apply the Inline Method refactoring when a method's behavior is simple and its purpose is clear, but it is called from only one place.
If the method has become redundant or does not add significant value, it can be safely inlined.

Expand Down
2 changes: 0 additions & 2 deletions InliningCode/InlineMethodRefactoring/lesson-info.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
type: framework
custom_name: What is Inline Method refactoring?
content:
- Theory
- InlineMethodAndVariables
is_template_based: false

0 comments on commit 8c9ce9a

Please sign in to comment.