Last active
August 28, 2022 17:39
-
-
Save vivek-vijayan/2a7565c8c7128b1112edef0a6ad580c8 to your computer and use it in GitHub Desktop.
Go program for payroll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package payroll | |
type Employee struct { | |
Empid int // public variable as the Empid starts with upper case | |
empname string // private variable as the empname starts with lowercase | |
salary int // private variable as the empname starts with lowercase | |
} | |
func (emp *Employee) AddEmployeeDetails(name string, salary int) { | |
emp.SetEmpName(name) | |
emp.SetSalary(salary) | |
} | |
// Setters | |
func (e *Employee) SetEmpName(name string) { | |
e.empname = name | |
} | |
func (e *Employee) SetSalary(salary int) { | |
e.salary = salary | |
} | |
func (e *Employee) SetEmpID(id int) { | |
e.Empid = id | |
} | |
// Getters | |
func (e *Employee) ShowEmpName() string { | |
return e.empname | |
} | |
func (e *Employee) ShowSalary() int { | |
return e.salary | |
} | |
func (e *Employee) ShowEmpId() int { | |
return e.Empid | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment