This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RestaurantFavoritePageProvider({String id, bool isDetailPage}) { | |
_databaseHelper = DatabaseHelper(); | |
loadFavoriteRestaurant(); | |
if (isDetailPage) { | |
checkIfRestaurantIsFavorite(id); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Database { | |
fun read(): String | |
fun create(): String | |
} | |
class MySQL: Database { | |
override fun read() = "MYSQL read database" | |
override fun create() = "MYSQL create database" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Payment { | |
val paymentName: String | |
} | |
interface Bank: Payment { | |
val noCard: Int | |
} | |
interface Digital: Payment { | |
val tagname: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date | |
interface Product { | |
val name: String | |
} | |
interface FoodProduct: Product { | |
val expiredDate: Date | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class Shipping { | |
JNE, JNT | |
} | |
class Product() { | |
fun calculateShippingPrice(price: Int, shipping: Shipping): Int{ | |
return when(shipping){ | |
Shipping.JNE -> 12 * price | |
Shipping.JNT -> 20 * price | |
else -> 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Repository(){ | |
fun getData(): String { | |
return dataSource() | |
} | |
fun dataSource(): String { | |
return "data from datasource!" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"approved":["fun main val valueA 101 val valueB 52 val valueC 99 val resultA calculateResult valueA valueB valueC val resultB calculateResult valueA valueB null println ResultA is resultA ResultB is resultB trimIndent fun calculateResult valueA Int valueB Int valueC Int Int TODO val valueC if valueC null valueC else 50 val result valueA valueB valueC return result","fun main TODO 1 val vehicle mapOf String String type to Motorcycle maxSpeed to 230Km s maxTank to 10Ltr TODO 2 val type vehicle type val maxSpeed vehicle maxSpeed val maxTank vehicle maxTank TODO 3 println Vehicle println Type type println Maximal Speed maxSpeed println Maximal Tank maxTank","fun main val kotlin Kotlin getFirstAndLast val dicoding Dicoding getFirstAndLast val kotlinFirstChar kotlin first val kotlinLastChar kotlin last val dicodingFirstChar dicoding first val dicodingLastChar dicoding last println First char Kotlin is kotlinFirstChar and kotlinLastChar for second letter println First char Dicoding is dicodingFirstChar and dicoding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"data":"approved","code":["funmain(){valvalueA=101valvalueB=52valvalueC=99valresultA=calculateResult(valueA,valueB,valueC)valresultB=calculateResult(valueA,valueB,null)println(\"\"\"ResultAis$resultAResultBis$resultB\"\"\".trimIndent())}funcalculateResult(valueA:Int,valueB:Int,valueC:Int?):Int{//TODOvalvalueC=if(valueC!=null)valueCelse50valresult=valueA+(valueB-valueC)returnresult}","funmain(){//TODO1valvehicle=mapOf<String,String>(\"type\"to\"Motorcycle\",\"maxSpeed\"to\"230Km/s\",\"maxTank\"to\"10Ltr\")//TODO2valtype=(vehicle[\"type\"])valmaxSpeed=(vehicle[\"maxSpeed\"])valmaxTank=(vehicle[\"maxTank\"])//TODO3println(\"Vehicle\")println(\"Type:$type\")println(\"MaximalSpeed:$maxSpeed\")println(\"MaximalTank:$maxTank\")}","funmain(){valkotlin=\"Kotlin\".getFirstAndLast()valdicoding=\"Dicoding\".getFirstAndLast()valkotlinFirstChar=kotlin[\"first\"]valkotlinLastChar=kotlin[\"last\"]valdicodingFirstChar=dicoding[\"first\"]valdicodingLastChar=dicoding[\"last\"]println(\"FirstcharKotlinis$kotlinFirstCharand$kotl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"submission": { | |
"approved": [ | |
"/***Untukmenyelesaikantugaslatihan,Andatidakdiperbolehkanmengubahstrukturkodeyangsudahada.Kecuali:*-Untukmelakukanimprovisasikode*-Mengikutiperintahyangada**Cukuptambahkankodeberdasarkanperintahyangsudahditentukan.**/funmain(){vallistNumber=1.rangeTo(100)for(numberinlistNumber){//TODO1if(number%2==0)continue//TODO2if(number>15)break//TODO3valresult=number*(number+10)println(\"rangeresultis$result\")}}", | |
"/***Untukmenyelesaikantugaslatihan,Andatidakdiperbolehkanmengubahstrukturkodeyangsudahada.Kecuali:*-Untukmelakukanimprovisasikode*-Mengikutiperintahyangada**Cukuptambahkankodeberdasarkanperintahyangsudahditentukan.**/importkotlinx.coroutines.*//TODO1suspendfunsum(valueA:Int,valueB:Int):Int{delay(3000)returnvalueA+valueB}//TODO2suspendfunmultiple(valueA:Int,valueB:Int):Int{delay(2000)returnvalueA*valueB}funmain()=runBlocking{println(\"Counting...\")valresultSum=async{sum(10,10)}valresultMultiple=async{multiple(20,20)}//TODO3println(\"Resultsum:${resultSum.awai |