From 10d7bbfdf2b610ab9971f3fac7ff72e95ecd47cb Mon Sep 17 00:00:00 2001 From: "JaringanKantor.com" Date: Fri, 15 Oct 2021 23:03:33 +0700 Subject: [PATCH] interface update --- biodata.go | 14 ++++++++++++++ kalkulator.go | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/biodata.go b/biodata.go index 993a056..6673d89 100644 --- a/biodata.go +++ b/biodata.go @@ -33,3 +33,17 @@ func TampilData() { func (pegawai Pegawai) SelamatDatang(nama string) { fmt.Println("Selamat datang", nama, "giat bekerja ya pak", pegawai.Nama) } + +func AnonymousDataOrtu() { + OrangTua := struct { + Usia int8 + NamaOrtu string + Hidup bool + }{ + Usia: 63, + NamaOrtu: "Syahroni", + Hidup: true, + } + + fmt.Println(OrangTua) +} diff --git a/kalkulator.go b/kalkulator.go index 5a4403b..94fe2e6 100644 --- a/kalkulator.go +++ b/kalkulator.go @@ -2,6 +2,23 @@ package module import "fmt" +type PersegiInterface interface { + Keliling() int + Luas() int +} + +type InputPersegi struct { + a, b int +} + +func (in InputPersegi) Keliling() int { + return (in.a + in.b) * 2 +} + +func (in InputPersegi) Luas() int { + return in.a * in.b +} + func About() { fmt.Println("Ini adalah fungsi kalkulator") }