diff --git a/app/src/main/kotlin/manager/CollectionManager.kt b/app/src/main/kotlin/manager/CollectionManager.kt index af8551e..88484f7 100644 --- a/app/src/main/kotlin/manager/CollectionManager.kt +++ b/app/src/main/kotlin/manager/CollectionManager.kt @@ -8,12 +8,16 @@ class CollectionManager( private val io: IOHandler, ) { private val list = LinkedList() - private var currId = 1L + private var currProductId = 1L fun addProduct(product: Product) { - val productWithId = product.copy(id = currId) - list.add(productWithId) - currId++ + list.add(generateProductId(product)) io.println(list.toString()) } + + fun generateProductId(product: Product): Product { + val productId = product.copy(id = currProductId) + currProductId++ + return productId + } }