Skip to content

Instantly share code, notes, and snippets.

@omayib
Created November 6, 2019 07:53
Show Gist options
  • Save omayib/5e1991027226dd5cffcdc65641a2c6ae to your computer and use it in GitHub Desktop.
Save omayib/5e1991027226dd5cffcdc65641a2c6ae to your computer and use it in GitHub Desktop.
fun main(args:Array<String>){
var view1 = ViewPage1()
view1.main()
var view2 = ViewPage2()
view2.main()
var view3 = ViewPage3()
view3.main()
}
class ViewPage1{
fun main(){
var presenter1 = PresenterPage1()
println("view1:"+presenter1.ambilMobil())
}
}
class ViewPage2{
fun main(){
var presenter2 = PresenterPage2()
println("view2:"+presenter2.tampilkanServices())
}
}
class ViewPage3{
fun main(){
var presenter3 = PresenterPage3()
println("view3:"+presenter3.ambilMobil())
println("view3:"+presenter3.tampilkanServices())
println("view3:"+presenter3.voucherTersedia())
}
}
// presenters
class PresenterPage1{
private var carManager:CarManager
init {
carManager = CarManager()
}
fun ambilMobil():List<String>{
return carManager.getCars().sorted()
}
}
class PresenterPage2{
private var servicesManager:ServicesManager
init {
servicesManager = ServicesManager()
}
fun tampilkanServices():List<String> {
return servicesManager.getServices().sorted()
}
}
class PresenterPage3{
private var carManager:CarManager
private var servicesManager:ServicesManager
private var voucherManager: VoucherManager
init {
carManager = CarManager()
servicesManager = ServicesManager()
voucherManager = VoucherManager()
}
fun ambilMobil():List<String>{
return carManager.getCars().sorted()
}
fun tampilkanServices():List<String> {
return servicesManager.getServices().sorted()
}
fun voucherTersedia():List<String>{
return voucherManager.getVouchers().sorted()
}
}
//reusable func
class CarManager{
fun getCars(): List<String> {
var a = listOf<String>("anaza","picanto","camry")
return a
}
}
class ServicesManager(){
fun getServices(): List<String>{
return listOf("cucikering","gantioli","tuneup")
}
}
class VoucherManager(){
fun getVouchers(): List<String>{
return listOf("hepiyadara","merdeka","hepiselalu","hepiteam")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment