Finished chap 10 and 11

This commit is contained in:
John O'Keefe 2024-01-31 14:45:10 -05:00
parent 3ccf860ffc
commit 943191e9dd
5 changed files with 46 additions and 2 deletions

View File

@ -1,6 +1,24 @@
// from chapter 10
package main
func calendar() {
import (
"fmt"
"git.linuxhg.com/Go_Training/calendar"
)
func companyCalendar() {
event := calendar.Event{}
err := event.SetTitle("Mom's Birthday")
Error(err)
err = event.SetYear(2019)
Error(err)
err = event.SetMonth(5)
Error(err)
err = event.SetDay(27)
Error(err)
fmt.Println(event.Title())
fmt.Println(event.Year())
fmt.Println(event.Month())
fmt.Println(event.Day())
}

View File

@ -5,9 +5,23 @@ package main
import "fmt"
type Liters float64
func (l Liters) String() string {
return fmt.Sprintf("%0.2f L", l)
}
type Gallons float64
func (g Gallons) String() string {
return fmt.Sprintf("%0.2f gal", g)
}
type Milliliters float64
func (m Milliliters) String() string {
return fmt.Sprintf("%0.2f mL", m)
}
func (l Liters) ToGallons() Gallons {
return Gallons(l * 0.264)
}
@ -46,4 +60,7 @@ func fuel() {
milk := Gallons(2)
fmt.Printf("%0.0f gallons equals %0.3f liters\n", milk, milk.ToLiters())
fmt.Printf("%0.0f gallons equals %0.3f milliliters\n", milk, milk.ToMilliliters())
fmt.Println(Gallons(12.09285934))
fmt.Println(Liters(12.09285934))
fmt.Println(Milliliters(12.09285934))
}

View File

@ -13,6 +13,7 @@ require (
)
require (
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131153240-372e0ebc267d // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect

View File

@ -1,3 +1,11 @@
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131021259-9a867797a789 h1:NjOZBosOrGRV87iw30jOyH8UNKv7bVNxtix+BguskVA=
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131021259-9a867797a789/go.mod h1:E6GYPXO26PAOFhtrQ3d9K+yG0j6e4nFORZT5zlD7HOc=
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131145407-3e70d7233820 h1:/n9lYFbddduk4UoGW0Jh12synMzF02ciC3gCkrqph5g=
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131145407-3e70d7233820/go.mod h1:E6GYPXO26PAOFhtrQ3d9K+yG0j6e4nFORZT5zlD7HOc=
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131150458-66340adc88a8 h1:UTF7JbrCemR61hRKderfV3Au3/0CFDIIefp70YalEww=
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131150458-66340adc88a8/go.mod h1:E6GYPXO26PAOFhtrQ3d9K+yG0j6e4nFORZT5zlD7HOc=
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131153240-372e0ebc267d h1:wKAe1v8k2qmtJUo/FgE2xqdLRNN31u01bT9/FQGr0MI=
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131153240-372e0ebc267d/go.mod h1:E6GYPXO26PAOFhtrQ3d9K+yG0j6e4nFORZT5zlD7HOc=
git.linuxhg.com/Go_Training/datafile v0.0.0-20240111160218-6989e96515a9 h1:jjPk3X9lZ6bZhsjBvEJUGyqfNalUDG0Lt5UvaPrKFtM=
git.linuxhg.com/Go_Training/datafile v0.0.0-20240111160218-6989e96515a9/go.mod h1:iRnsnz7UZZtIhCX3KTblxBxtEuvPZ8MMi5GDWGIt+dw=
git.linuxhg.com/Go_Training/keyboard v0.0.0-20240111160241-d208f095efce h1:S9raWDpQtH3at5D4Bm0bfnvPd3ATGGMuZ8eQMrLddFM=

View File

@ -113,7 +113,7 @@ func main() {
{
name: "Calendar",
launchFunction: func() {
calendar()
companyCalendar()
},
},
}