Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[둘리] 2단계 자동차 경주 제출합니다. #68

Merged
merged 12 commits into from
Feb 15, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
refactor(Cars): backing property 삭제
  • Loading branch information
hyemdooly committed Feb 14, 2023
commit 90c2b1d8677c3efa0f1a40f388c60e281368ec46
12 changes: 4 additions & 8 deletions src/main/kotlin/model/Cars.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package model

class Cars(cars: List<Car>) {
private val _cars: List<Car> = cars
val cars: List<Car> get() = _cars

class Cars(val cars: List<Car>) {
constructor(input: String) : this(input.split(",").mapIndexed { _, name -> Car(name.trim()) })

fun getCar(index: Int): Car = _cars[index]
fun getCarSize(): Int = _cars.size
fun getCar(index: Int): Car = cars[index]
fun getCarSize(): Int = cars.size
fun move(index: Int, condition: Int) {
_cars[index].move(condition)
cars[index].move(condition)
}
}