7. Interfaces
Activity 7.01: Calculating Pay and Performance Review
Solution:
- Create a
main.go
file. - Inside the
main.go
file, we have amain
package and we need to import theerrors
,fmt
, andos
packages:package main import ( "errors" "fmt" "os" )
- Create the
Employee
struct as follows:type Employee struct { Id int FirstName string LastName string }
- Create the
Developer
struct. TheDeveloper
struct has theEmployee
struct embedded into it:type Developer struct { Individual Employee HourlyRate float64 HoursWorkedInYear float64 Review map[string]interface{} }
- Create the
Manager
struct; it will have theEmployee
struct embedded into it as well:type Manager struct { Individual Employee Salary float64 CommissionRate float64 }
- The...