-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.go
83 lines (66 loc) · 1.9 KB
/
Main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"fmt"
"os"
)
func main() {
accountDepositChannel := make(chan *BankAccount) //account deposit chan
accountWithdrawChannel := make(chan *BankAccount) //account withdraw chan
amountDepositChannel := make(chan int) //amount deposit chan
amountWithdrawChannel := make(chan int) //amount withdraw chan
go deposit(accountDepositChannel, amountDepositChannel)
go withdraw(accountWithdrawChannel, amountWithdrawChannel)
var username, password string
username, password = login()
var choice, amount int
if accountKoen.holder == username && accountKoen.password == password || accountStijn.holder == username && accountStijn.password == password {
for {
fmt.Println("1) Zet geld op je rekening")
fmt.Println("2) Haal geld af")
fmt.Println("3) Schrijf over")
fmt.Println("4) Sluit af")
fmt.Print("Maak uw keuze: ")
fmt.Scan(&choice)
switch choice {
case 1:
fmt.Print("Bedrag: ")
fmt.Scan(&amount)
switch username {
case "Stijn":
accountDepositChannel <- &accountStijn
case "Koen":
accountDepositChannel <- &accountKoen
}
amountDepositChannel <- amount
fmt.Println(accountStijn, accountKoen)
case 2:
fmt.Print("Bedrag: ")
fmt.Scan(&amount)
switch username {
case "Stijn":
accountWithdrawChannel <- &accountStijn
case "Koen":
accountWithdrawChannel <- &accountKoen
}
amountWithdrawChannel <- amount
fmt.Println(accountStijn, accountKoen)
case 3:
fmt.Print("Bedrag: ")
fmt.Scan(&amount)
switch username {
case "Stijn":
accountWithdrawChannel <- &accountStijn
accountDepositChannel <- &accountKoen
case "Koen":
accountWithdrawChannel <- &accountKoen
accountDepositChannel <- &accountStijn
}
amountDepositChannel <- amount
amountWithdrawChannel <- amount
fmt.Println(accountStijn,accountKoen)
case 4:
os.Exit(0)
}
}
}
}