Exercise 1
This commit is contained in:
250
ex1/parsing/types.go
Normal file
250
ex1/parsing/types.go
Normal file
@@ -0,0 +1,250 @@
|
||||
package parsing
|
||||
|
||||
type Gender rune
|
||||
|
||||
const (
|
||||
Male Gender = 'M'
|
||||
Female Gender = 'F'
|
||||
)
|
||||
|
||||
type Quarter string
|
||||
|
||||
const (
|
||||
QuarterOne Quarter = "Q1"
|
||||
QuarterTwo Quarter = "Q2"
|
||||
QuarterThree Quarter = "Q3"
|
||||
QuarterFour Quarter = "Q4"
|
||||
)
|
||||
|
||||
func (x Quarter) Uint8() uint8 {
|
||||
switch x {
|
||||
case QuarterOne:
|
||||
return 1
|
||||
case QuarterTwo:
|
||||
return 2
|
||||
case QuarterThree:
|
||||
return 3
|
||||
case QuarterFour:
|
||||
return 4
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Half string
|
||||
|
||||
const (
|
||||
HalfOne Half = "H1"
|
||||
HalfTwo Half = "H2"
|
||||
)
|
||||
|
||||
func (x Half) Uint8() uint8 {
|
||||
switch x {
|
||||
case HalfOne:
|
||||
return 1
|
||||
case HalfTwo:
|
||||
return 2
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Month string
|
||||
|
||||
const (
|
||||
January Month = "January"
|
||||
February Month = "February"
|
||||
March Month = "March"
|
||||
April Month = "April"
|
||||
May Month = "May"
|
||||
June Month = "June"
|
||||
July Month = "July"
|
||||
August Month = "August"
|
||||
September Month = "September"
|
||||
October Month = "October"
|
||||
November Month = "November"
|
||||
December Month = "December"
|
||||
)
|
||||
|
||||
func (x Month) Uint8() uint8 {
|
||||
switch x {
|
||||
case January:
|
||||
return 1
|
||||
case February:
|
||||
return 2
|
||||
case March:
|
||||
return 3
|
||||
case April:
|
||||
return 4
|
||||
case May:
|
||||
return 5
|
||||
case June:
|
||||
return 6
|
||||
case July:
|
||||
return 7
|
||||
case August:
|
||||
return 8
|
||||
case September:
|
||||
return 9
|
||||
case October:
|
||||
return 10
|
||||
case November:
|
||||
return 11
|
||||
case December:
|
||||
return 12
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
type MonthShort string
|
||||
|
||||
const (
|
||||
Jan MonthShort = "Jan"
|
||||
Feb MonthShort = "Feb"
|
||||
Mar MonthShort = "Mar"
|
||||
Apr MonthShort = "Apr"
|
||||
MayShort MonthShort = "May"
|
||||
Jun MonthShort = "Jun"
|
||||
Jul MonthShort = "Jul"
|
||||
Aug MonthShort = "Aug"
|
||||
Sep MonthShort = "Sep"
|
||||
Oct MonthShort = "Oct"
|
||||
Nov MonthShort = "Nov"
|
||||
Dec MonthShort = "Dec"
|
||||
)
|
||||
|
||||
func (x MonthShort) Uint8() uint8 {
|
||||
switch x {
|
||||
case Jan:
|
||||
return 1
|
||||
case Feb:
|
||||
return 2
|
||||
case Mar:
|
||||
return 3
|
||||
case Apr:
|
||||
return 4
|
||||
case MayShort:
|
||||
return 5
|
||||
case Jun:
|
||||
return 6
|
||||
case Jul:
|
||||
return 7
|
||||
case Aug:
|
||||
return 8
|
||||
case Sep:
|
||||
return 9
|
||||
case Oct:
|
||||
return 10
|
||||
case Nov:
|
||||
return 11
|
||||
case Dec:
|
||||
return 12
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type WeekDay string
|
||||
|
||||
const (
|
||||
Monday WeekDay = "Monday"
|
||||
Tuesday WeekDay = "Tuesday"
|
||||
Wednesday WeekDay = "Wednesday"
|
||||
Thursday WeekDay = "Thursday"
|
||||
Friday WeekDay = "Friday"
|
||||
Saturday WeekDay = "Saturday"
|
||||
Sunday WeekDay = "Sunday"
|
||||
)
|
||||
|
||||
func (x WeekDay) Uint8() uint8 {
|
||||
switch x {
|
||||
case Monday:
|
||||
return 1
|
||||
case Tuesday:
|
||||
return 2
|
||||
case Wednesday:
|
||||
return 3
|
||||
case Thursday:
|
||||
return 4
|
||||
case Friday:
|
||||
return 5
|
||||
case Saturday:
|
||||
return 6
|
||||
case Sunday:
|
||||
return 7
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type WeekDayShort string
|
||||
|
||||
const (
|
||||
Mon WeekDayShort = "Mon"
|
||||
Tue WeekDayShort = "Tue"
|
||||
Wed WeekDayShort = "Wed"
|
||||
Thu WeekDayShort = "Thu"
|
||||
Fri WeekDayShort = "Fri"
|
||||
Sat WeekDayShort = "Sat"
|
||||
Sun WeekDayShort = "Sun"
|
||||
)
|
||||
|
||||
func (x WeekDayShort) Uint8() uint8 {
|
||||
switch x {
|
||||
case Mon:
|
||||
return 1
|
||||
case Tue:
|
||||
return 2
|
||||
case Wed:
|
||||
return 3
|
||||
case Thu:
|
||||
return 4
|
||||
case Fri:
|
||||
return 5
|
||||
case Sat:
|
||||
return 6
|
||||
case Sun:
|
||||
return 7
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
type Employee struct {
|
||||
EmpID uint32 `csv:"Emp ID"`
|
||||
NamePrefix string `csv:"Name Prefix"`
|
||||
FirstName string `csv:"First Name"`
|
||||
MiddleInitial string `csv:"Middle Initial"`
|
||||
LastName string `csv:"Last Name"`
|
||||
Gender Gender `csv:"Gender"`
|
||||
Email string `csv:"E Mail"`
|
||||
FathersName string `csv:"Father's Name"`
|
||||
MothersName string `csv:"Mothers's Name"`
|
||||
MothersMaidenName string `csv:"Mother's Maiden Name"`
|
||||
Birthdate string `csv:"Date of Birth"`
|
||||
BirthTime string `csv:"Time of Birth"`
|
||||
WeightKg uint16 `csv:"Weight in Kgs."`
|
||||
JoiningDate string `csv:"Date of Joining"`
|
||||
JoiningQuarter Quarter `csv:"Quarter of Joining"`
|
||||
JoiningHalf Half `csv:"Half of Joining"`
|
||||
JoiningYear uint16 `csv:"Year of Joining"`
|
||||
JoiningMonth uint8 `csv:"Month of Joining"`
|
||||
JoiningMonthName Month `csv:"Month Name of Joining"`
|
||||
JoiningMonthNameShort MonthShort `csv:"Short Month"`
|
||||
JoiningMonthDay uint8 `csv:"Day of Joining"`
|
||||
JoiningWeekDay WeekDay `csv:"DOW of Joining"`
|
||||
JoiningWeekDayShort WeekDayShort `csv:"Short DOW"`
|
||||
YearsOfService float32 `csv:"Age in Company (Years)"`
|
||||
Salary uint32 `csv:"Salary"`
|
||||
LatestHikePercentage string `csv:"Last % Hike"`
|
||||
SSN string `csv:"SSN"`
|
||||
PhoneNumber string `csv:"Phone No."`
|
||||
PlaceName string `csv:"Place Name"`
|
||||
County string `csv:"County"`
|
||||
City string `csv:"City"`
|
||||
State string `csv:"State"`
|
||||
Zip uint32 `csv:"Zip"`
|
||||
Region string `csv:"Region"`
|
||||
Username string `csv:"User Name"`
|
||||
Password string `csv:"Password"`
|
||||
// Empty slot
|
||||
// Empty slot
|
||||
// Empty slot
|
||||
}
|
||||
Reference in New Issue
Block a user