Skip to content

Commit 43864f2

Browse files
committed
Сделал вывод целого массива без использования итератора
1 parent 68a26be commit 43864f2

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

app/src/main/java/com/apochromat/codeblockmobile/logic/ConsoleInput.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ class ConsoleInput : Block() {
6363
status = variableAssignSequence()
6464
return
6565
}
66-
if (obj.first != tagArray()) {
66+
// костыль
67+
if (obj.first != tagArray() && !heap.isArrayExist(name)) {
6768
status = obj.first
6869
return
6970
}
70-
if (stringList.size != heap.getArraySize(obj.second)) {
71+
if (stringList.size != heap.getArraySize(name)) {
7172
status = sizesMismatch()
7273
return
7374
}

app/src/main/java/com/apochromat/codeblockmobile/logic/ConsoleOutput.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class ConsoleOutput : Block() {
2828
adapterConsole.addMessage(message)
2929
return
3030
}
31+
if (heap.isArrayExist(expression)) {
32+
adapterConsole.addMessage("$message[${heap.getArray(expression)?.joinToString()}]")
33+
return
34+
}
3135
val calculated = arithmetics(heap, expression)
3236
status = calculated.first
3337
if (calculated.first != ok()) return

app/src/main/java/com/apochromat/codeblockmobile/logic/Heap.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ class Heap {
8383
return heapArray[arrayName]?.get(index)
8484
}
8585

86+
/**
87+
* Получить значение массив.
88+
**/
89+
fun getArray(arrayName: String): Array<Int>? {
90+
return heapArray[arrayName]
91+
}
92+
8693
/**
8794
* Существует ли массив.
8895
**/

0 commit comments

Comments
 (0)