From 9c6d86214eff4772630c33e3e4435d92cc619cc2 Mon Sep 17 00:00:00 2001 From: Vitor Lopes Date: Thu, 29 Feb 2024 01:27:15 -0300 Subject: [PATCH 1/3] First commit --- build.gradle.kts | 1 + src/main/kotlin/Main.kt | 31 ++++++++++++++++++++-- src/main/kotlin/dataRestaurants.json | 39 ++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/dataRestaurants.json diff --git a/build.gradle.kts b/build.gradle.kts index 6ace7a7..602e31f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,7 @@ repositories { dependencies { testImplementation("org.jetbrains.kotlin:kotlin-test") + implementation ("com.google.code.gson:gson:2.8.7") } tasks.test { diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index 0a9890e..f8f8ac2 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -1,7 +1,34 @@ -package org.example +import com.google.gson.Gson +import java.io.File + +data class Address( + val street: String, + val number: String, + val cep: String, + val city: String, + val state: String, + val country: String +) + +data class Itinerary( + val day: String, + val startTime: String, + val endTime: String +) + +data class Restaurante( + val name: String, + val rating: Double, + val address: Address, + val itinerary: List +) fun main() { - println("Hello World!") + val jsonFile = File("/Users/vitorlopes/Documents/Biped/Gradle/codelab/src/main/kotlin/dataRestaurants.json") + val json = jsonFile.readText() + + val restaurante = Gson().fromJson(json, Restaurante::class.java) + println(restaurante) } /** diff --git a/src/main/kotlin/dataRestaurants.json b/src/main/kotlin/dataRestaurants.json new file mode 100644 index 0000000..bbd44c9 --- /dev/null +++ b/src/main/kotlin/dataRestaurants.json @@ -0,0 +1,39 @@ +{ + "name": "Ah!Butequeria", + "rating": 4.9, + "address": { + "street": "Rua Paulo Frontim", + "number": "240", + "cep": "30430012", + "city": "Curvelo", + "state": "Minas Gerais", + "country": "Brazil" + }, + "itinerary": [ + { + "day": "2024-03-04", + "startTime": "9:00 AM", + "endTime": "6:00 PM" + }, + { + "day": "2024-03-05", + "startTime": "9:00 AM", + "endTime": "6:00 PM" + }, + { + "day": "2024-03-06", + "startTime": "9:00 AM", + "endTime": "6:00 PM" + }, + { + "day": "2024-03-07", + "startTime": "9:00 AM", + "endTime": "6:00 PM" + }, + { + "day": "2024-03-08", + "startTime": "9:00 AM", + "endTime": "6:00 PM" + } + ] +} \ No newline at end of file From 783819154ce44c52354d72a527a461f3ae2e138f Mon Sep 17 00:00:00 2001 From: Vitor Date: Wed, 20 Mar 2024 02:09:02 -0300 Subject: [PATCH 2/3] =?UTF-8?q?Criei=20a=20classe=20CommercialPlace=20ela?= =?UTF-8?q?=20que=20cont=C3=A9m=20propriedades=20comuns=20entre=20as=20cla?= =?UTF-8?q?sses=20Restaurants=20e=20CoffeeShop,=20usando=20o=20conceito=20?= =?UTF-8?q?de=20polimorfismo=20para=20resolver=20o=20problema.=20Criei=20t?= =?UTF-8?q?amb=C3=A9m=20uma=20fun=C3=A7=C3=A3o=20prettyPrint=20que=20verif?= =?UTF-8?q?ica=20qual=20classe=20=C3=A9,=20e=20exibi=20na=20tela=20conform?= =?UTF-8?q?e=20pedido.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/codeStyles/Project.xml | 10 ++ .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/gradle.xml | 3 +- build.gradle.kts | 2 +- src/main/kotlin/Main.kt | 73 ++++++----- src/main/kotlin/dataRestaurants.json | 173 +++++++++++++++++++++++++-- 6 files changed, 229 insertions(+), 37 deletions(-) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..1bec35e --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 14746e7..622f299 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,10 +1,11 @@ +