-
Notifications
You must be signed in to change notification settings - Fork 524
/
main.go
56 lines (47 loc) · 1.11 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
package main
import (
"fmt"
m2 "personal-budget/module2"
"time"
)
var months = []time.Month{
time.January,
time.February,
time.March,
time.April,
time.May,
time.June,
time.July,
time.August,
time.September,
time.October,
time.November,
time.December,
time.January,
}
func main() {
bu, _ := m2.CreateBudget(time.January, 1000)
bu.AddItem("bananas", 10.0)
fmt.Println("Items in January:", len(bu.Items))
fmt.Printf("Current cost for January: $%.2f \n", bu.CurrentCost())
m2.CreateBudget(time.February, 1000)
bu2 := m2.GetBudget(time.February)
bu2.AddItem("bananas", 10.0)
bu2.AddItem("coffee", 3.99)
bu2.AddItem("gym", 50.0)
bu2.RemoveItem("coffee")
fmt.Println("Items in February:", len(bu2.Items))
fmt.Printf("Current cost for February: $%.2f \n", bu2.CurrentCost())
fmt.Println("Resetting Budget Report...")
m2.InitializeReport()
for _, month := range months {
_, err := m2.CreateBudget(month, 100.00)
if err == nil {
fmt.Println("Budget created for", month)
} else {
fmt.Println("Error creating budget:", err)
}
}
_, err := m2.CreateBudget(time.December, 100.00)
fmt.Println(err)
}