learned I didn't need git for external modules and different folders can have different mains
This commit is contained in:
56
pkg/calendar/date.go
Normal file
56
pkg/calendar/date.go
Normal file
@ -0,0 +1,56 @@
|
||||
package calendar
|
||||
|
||||
import "errors"
|
||||
|
||||
// Date Struct
|
||||
type Date struct {
|
||||
year int
|
||||
month int
|
||||
day int
|
||||
}
|
||||
|
||||
// Setter Methods
|
||||
|
||||
// SetYear Method
|
||||
func (d *Date) SetYear(year int) error {
|
||||
if year < 1 {
|
||||
return errors.New("invalid year")
|
||||
}
|
||||
d.year = year
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetMonth Method
|
||||
func (d *Date) SetMonth(month int) error {
|
||||
if month < 1 || month > 12 {
|
||||
return errors.New("invalid month")
|
||||
}
|
||||
d.month = month
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetDay Method
|
||||
func (d *Date) SetDay(day int) error {
|
||||
if day < 1 || day > 31 {
|
||||
return errors.New("invalid day")
|
||||
}
|
||||
d.day = day
|
||||
return nil
|
||||
}
|
||||
|
||||
// Getter Methods
|
||||
|
||||
// Year Method
|
||||
func (d *Date) Year() int {
|
||||
return d.year
|
||||
}
|
||||
|
||||
// Month Method
|
||||
func (d *Date) Month() int {
|
||||
return d.month
|
||||
}
|
||||
|
||||
// Day Method
|
||||
func (d *Date) Day() int {
|
||||
return d.day
|
||||
}
|
23
pkg/calendar/event.go
Normal file
23
pkg/calendar/event.go
Normal file
@ -0,0 +1,23 @@
|
||||
package calendar
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
title string
|
||||
Date
|
||||
}
|
||||
|
||||
func (e *Event) Title() string {
|
||||
return e.title
|
||||
}
|
||||
|
||||
func (e *Event) SetTitle(title string) error {
|
||||
if utf8.RuneCountInString(title) > 32 {
|
||||
return errors.New("invalid title length")
|
||||
}
|
||||
e.title = title
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user