diff --git a/src/Main.kt b/src/Main.kt index a7a5e00..13c3c4e 100644 --- a/src/Main.kt +++ b/src/Main.kt @@ -1,3 +1,30 @@ fun main() { - println("Hello World!") + +// var book1 = Book() +// book1.author = "Hussain" +// book1.title = "Life and Challenges" +// book1.yearPublished = 2019 + + var book1 = Book("Life and Challenges", "Hussain", 2019) + book1.getBookInfo() +} + +//class Book(){ +// var title: String = "" +// var author: String = "" +// var yearPublished: Int = 0 +//} + + + +class Book constructor(var title: String, var author: String, var yearPublished: Int) { + var genre: String ?= null + + fun getBookInfo() { + if (genre == null) { + println("$title, By: $author ($yearPublished)") + } else { + println("$title, By: $author, ($yearPublished) ($genre)") + } + } } \ No newline at end of file