Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/tutorial-go.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions golang-basic/09-structs-interfaces/first-struct-area.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
"math"
)

type Circle struct {
type Circles struct {
x, y, r float64
}

func circleArea(c *Circle) float64 {
func circleArea(c *Circles) float64 {
return math.Pi * c.r * c.r
}

func main() {
c := Circle{0, 0, 5}
c := Circles{0, 0, 5}
fmt.Println(circleArea(&c))
}
4 changes: 2 additions & 2 deletions golang-basic/09-structs-interfaces/manual-function.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func rectangleArea(x1, y1, x2, y2 float64) float64 {
return l * w
}

func circleArea(x, y, r float64) float64 {
func circleAreas(x, y, r float64) float64 {
return math.Pi * r * r
}

Expand All @@ -26,5 +26,5 @@ func main() {
var rx2, ry2 float64 = 10, 10
var cx, cy, cr float64 = 0, 0, 5
fmt.Println(rectangleArea(rx1, ry1, rx2, ry2))
fmt.Println(circleArea(cx, cy, cr))
fmt.Println(circleAreas(cx, cy, cr))
}
42 changes: 42 additions & 0 deletions golang-basic/latihan/01-noverry-ambo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Soal 1
Buat program `palindrome` menggunakan golang

$ go main.go
$ madam

output
true

*/

package main

import "fmt"

func isPalindrome(input string) bool {

for i := 0; i < len(input)/2; i++ {
if input[i] != input[len(input)-i-1] {
return false
}
}
return true
}

func main() {

var str string

fmt.Print("Cek Palindrome : ")
fmt.Scan(&str)

result := isPalindrome(str)

if result == true {
fmt.Println("true")
} else {
fmt.Println("false")
}

}
38 changes: 38 additions & 0 deletions golang-basic/latihan/02-noverry-ambo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Soal 2
Buat program untuk menentukan Huruf yang diinput Vokal atau Konsonan
>>> input
$ go main .go
h
>>> output
Konsonan
*/

package main

import "fmt"

func isVocal(vocal string) string {

if vocal == "a" || vocal == "e" || vocal == "i" || vocal == "o" || vocal == "u" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bisa ditambahkan buat terlebih dahulu input-nya menjadi uppercase atw lowercase biar bisa diseragamkan

vocal = "Vokal"
} else {
vocal = "Konsonan"
}

return vocal
}

func main() {
var vocal string
fmt.Print("Masukkan huruf : ")
fmt.Scan(&vocal)

result := isVocal(vocal)

if result == "Vokal" {
fmt.Println("Vokal")
} else {
fmt.Println("Konsonan")
}

}
11 changes: 11 additions & 0 deletions gomodule-unit-test/latihan/03-noverry-ambo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

func isVocal(vocal string) string {

if vocal == "a" || vocal == "e" || vocal == "i" || vocal == "o" || vocal == "u" {
vocal = "Vokal"
} else {
vocal = "Konsonan"
}
return vocal
}
26 changes: 26 additions & 0 deletions gomodule-unit-test/latihan/03-noverry-ambo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import "testing"

func Test_isVocal(t *testing.T) {
type args struct {
vocal string
}
tests := []struct {
name string
args args
want string
}{
{
name: "konsonan or vocal",
args: args{
vocal: "madam",
},
want: "Konsonan",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
})
}
}
11 changes: 11 additions & 0 deletions gomodule-unit-test/latihan/04-noverry-ambo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

func isPalindrome(input string) bool {

for i := 0; i < len(input)/2; i++ {
if input[i] != input[len(input)-i-1] {
return false
}
}
return true
}
33 changes: 33 additions & 0 deletions gomodule-unit-test/latihan/04-noverry-ambo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import "testing"

func Test_isPalindrome(t *testing.T) {
type args struct {
input string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "konsonan or vocal",
args: args{
input: "madam",
},
want: true,
},
{
name: "konsonan or vocal",
args: args{
input: "rusak",
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
})
}
}