From b59f5b2fb3bd137ea5170a2dc453b92f4d9a8a8b Mon Sep 17 00:00:00 2001 From: Mishal Alquraini Date: Sun, 16 Feb 2025 17:59:24 +0300 Subject: [PATCH 1/4] done with parts 1 --- Task part 1/.gitignore | 32 +++++++++++++++++++ Task part 1/.idea/.gitignore | 3 ++ .../inspectionProfiles/Project_Default.xml | 6 ++++ Task part 1/.idea/kotlinc.xml | 10 ++++++ .../.idea/libraries/KotlinJavaRuntime.xml | 17 ++++++++++ Task part 1/.idea/misc.xml | 6 ++++ Task part 1/.idea/modules.xml | 8 +++++ Task part 1/.idea/vcs.xml | 6 ++++ Task part 1/Task part 1.iml | 15 +++++++++ Task part 1/src/Main.kt | 18 +++++++++++ 10 files changed, 121 insertions(+) create mode 100644 Task part 1/.gitignore create mode 100644 Task part 1/.idea/.gitignore create mode 100644 Task part 1/.idea/inspectionProfiles/Project_Default.xml create mode 100644 Task part 1/.idea/kotlinc.xml create mode 100644 Task part 1/.idea/libraries/KotlinJavaRuntime.xml create mode 100644 Task part 1/.idea/misc.xml create mode 100644 Task part 1/.idea/modules.xml create mode 100644 Task part 1/.idea/vcs.xml create mode 100644 Task part 1/Task part 1.iml create mode 100644 Task part 1/src/Main.kt diff --git a/Task part 1/.gitignore b/Task part 1/.gitignore new file mode 100644 index 0000000..3ddbf4c --- /dev/null +++ b/Task part 1/.gitignore @@ -0,0 +1,32 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Kotlin ### +.kotlin + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/Task part 1/.idea/.gitignore b/Task part 1/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Task part 1/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Task part 1/.idea/inspectionProfiles/Project_Default.xml b/Task part 1/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..df543e3 --- /dev/null +++ b/Task part 1/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/Task part 1/.idea/kotlinc.xml b/Task part 1/.idea/kotlinc.xml new file mode 100644 index 0000000..cba7a76 --- /dev/null +++ b/Task part 1/.idea/kotlinc.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/Task part 1/.idea/libraries/KotlinJavaRuntime.xml b/Task part 1/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..3e6dc71 --- /dev/null +++ b/Task part 1/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Task part 1/.idea/misc.xml b/Task part 1/.idea/misc.xml new file mode 100644 index 0000000..f03c948 --- /dev/null +++ b/Task part 1/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Task part 1/.idea/modules.xml b/Task part 1/.idea/modules.xml new file mode 100644 index 0000000..91c01ea --- /dev/null +++ b/Task part 1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Task part 1/.idea/vcs.xml b/Task part 1/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Task part 1/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Task part 1/Task part 1.iml b/Task part 1/Task part 1.iml new file mode 100644 index 0000000..43dd653 --- /dev/null +++ b/Task part 1/Task part 1.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Task part 1/src/Main.kt b/Task part 1/src/Main.kt new file mode 100644 index 0000000..285971a --- /dev/null +++ b/Task part 1/src/Main.kt @@ -0,0 +1,18 @@ + +class Book{ + var title: String = "" + var author: String = "" + var yearPublished: Int = 2000 + +// fun info(): String{ +// return "Title: $title Author: " +// } +} + +fun main() { + var myBook = Book() + + myBook.author = "Mishal" + myBook.title = "Journey" + myBook.yearPublished = 2025 +} \ No newline at end of file From 23871b3418c023ab13729959567f498f6015dac2 Mon Sep 17 00:00:00 2001 From: Mishal Alquraini Date: Sun, 16 Feb 2025 18:34:10 +0300 Subject: [PATCH 2/4] done with part 2 --- Task part 1/src/Main.kt | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/Task part 1/src/Main.kt b/Task part 1/src/Main.kt index 285971a..743a408 100644 --- a/Task part 1/src/Main.kt +++ b/Task part 1/src/Main.kt @@ -1,18 +1,33 @@ -class Book{ - var title: String = "" - var author: String = "" - var yearPublished: Int = 2000 +// title after book = its a requirement (constructor +// it can be after Book or write constructor +class Book(var title: String, var author: String, var yearPublished: Int){ +// var title: String = "" +// var author: String = "" +// var yearPublished: Int = 2000 +// constructor(title: String, author: String, yearPublished: Int) -// fun info(): String{ -// return "Title: $title Author: " -// } + fun info(){ + println("title= $title, author: $author, Published: $yearPublished") + } } +// name = primary constructor , accNum is a secondary constructor +class bankAcc(var name: String) { + constructor( accountNum: Int): this("") + fun printInfo(){ + println("Account Holder: $name") + } +} + fun main() { - var myBook = Book() + var nbkAcc = bankAcc("Mishal") + nbkAcc.printInfo() + + var myBook = Book("Journey", "Mishal", 20205) +// myBook.author = "Mishal" +// myBook.title = "Journey" +// myBook.yearPublished = 2025 + myBook.info() - myBook.author = "Mishal" - myBook.title = "Journey" - myBook.yearPublished = 2025 } \ No newline at end of file From 030be836cbcabcefa60f5b9dde9464e3fdc79edd Mon Sep 17 00:00:00 2001 From: Mishal Alquraini Date: Sun, 16 Feb 2025 18:40:35 +0300 Subject: [PATCH 3/4] done --- Task part 1/src/Main.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Task part 1/src/Main.kt b/Task part 1/src/Main.kt index 743a408..92b6228 100644 --- a/Task part 1/src/Main.kt +++ b/Task part 1/src/Main.kt @@ -6,10 +6,12 @@ class Book(var title: String, var author: String, var yearPublished: Int){ // var author: String = "" // var yearPublished: Int = 2000 // constructor(title: String, author: String, yearPublished: Int) - - fun info(){ - println("title= $title, author: $author, Published: $yearPublished") - } +// fun info(){ +// println("title= $title, author: $author, Published: $yearPublished") +// } +fun getBookInfo(){ + println("$title by $author ($yearPublished)") +} } // name = primary constructor , accNum is a secondary constructor class bankAcc(var name: String) { @@ -28,6 +30,6 @@ fun main() { // myBook.author = "Mishal" // myBook.title = "Journey" // myBook.yearPublished = 2025 - myBook.info() - +// myBook.info() + myBook.getBookInfo() } \ No newline at end of file From 86b1d7e3a9802ab9816fb2e9f08e9915a38bd959 Mon Sep 17 00:00:00 2001 From: Mishal Alquraini Date: Sun, 16 Feb 2025 18:42:42 +0300 Subject: [PATCH 4/4] completed --- Task part 1/src/Main.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Task part 1/src/Main.kt b/Task part 1/src/Main.kt index 92b6228..aeb2a86 100644 --- a/Task part 1/src/Main.kt +++ b/Task part 1/src/Main.kt @@ -1,7 +1,7 @@ // title after book = its a requirement (constructor // it can be after Book or write constructor -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){ // var title: String = "" // var author: String = "" // var yearPublished: Int = 2000 @@ -10,7 +10,7 @@ class Book(var title: String, var author: String, var yearPublished: Int){ // println("title= $title, author: $author, Published: $yearPublished") // } fun getBookInfo(){ - println("$title by $author ($yearPublished)") + println("$title : $genre by $author ($yearPublished)") } } // name = primary constructor , accNum is a secondary constructor @@ -26,7 +26,7 @@ fun main() { var nbkAcc = bankAcc("Mishal") nbkAcc.printInfo() - var myBook = Book("Journey", "Mishal", 20205) + var myBook = Book("Journey", "Mishal", 20205, "Drama") // myBook.author = "Mishal" // myBook.title = "Journey" // myBook.yearPublished = 2025