From d12df9e14e9f60a72763439bbe060322b037fdeb Mon Sep 17 00:00:00 2001 From: azmenezi Date: Sun, 16 Feb 2025 17:32:02 +0300 Subject: [PATCH 1/3] new book classes --- src/Main.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Main.kt b/src/Main.kt index a7a5e00..2bebb11 100644 --- a/src/Main.kt +++ b/src/Main.kt @@ -1,3 +1,14 @@ fun main() { - println("Hello World!") + val book = Book() + book.title = "harry potter" + book.author = "humoud alghanim" + book.yearPublished = 2023 + + println(book) +} + +class Book { + var title: String = "" + var author: String = "" + var yearPublished: Int = 1900 } \ No newline at end of file From 8f0769187249569362c5bbdd231828cb2a9c813c Mon Sep 17 00:00:00 2001 From: azmenezi Date: Sun, 16 Feb 2025 18:31:11 +0300 Subject: [PATCH 2/3] done --- src/Main.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Main.kt b/src/Main.kt index 2bebb11..1a314cb 100644 --- a/src/Main.kt +++ b/src/Main.kt @@ -1,14 +1,11 @@ fun main() { - val book = Book() - book.title = "harry potter" - book.author = "humoud alghanim" - book.yearPublished = 2023 + val book = Book("Harry Potter", "Homoud Alghanim", 2000) - println(book) + book.getBookInfo() } -class Book { - var title: String = "" - var author: String = "" - var yearPublished: Int = 1900 +class Book(var title: String, var author: String, var yearPublished: Int) { + fun getBookInfo() { + println("$title by $author ($yearPublished)") + } } \ No newline at end of file From 6a23ab7637ad107fb54debd6612dda9633109316 Mon Sep 17 00:00:00 2001 From: azmenezi Date: Sun, 16 Feb 2025 18:35:40 +0300 Subject: [PATCH 3/3] challenge --- src/Main.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Main.kt b/src/Main.kt index 1a314cb..48048c3 100644 --- a/src/Main.kt +++ b/src/Main.kt @@ -1,11 +1,11 @@ fun main() { - val book = Book("Harry Potter", "Homoud Alghanim", 2000) + val book = Book("Harry Potter", "Homoud Alghanim", 2000, "action") book.getBookInfo() } -class Book(var title: String, var author: String, var yearPublished: Int) { +class Book(var title: String, var author: String, var yearPublished: Int, var genre: String) { fun getBookInfo() { - println("$title by $author ($yearPublished)") + println("$title by $author ($yearPublished) genre: $genre") } } \ No newline at end of file