Skip to content
Open
Changes from all commits
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
29 changes: 28 additions & 1 deletion src/Main.kt
Original file line number Diff line number Diff line change
@@ -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)")
}
}
}