-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #244 from Keezo0/Kostina_Polina_Alekseevna
lab5
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package lab5 | ||
|
||
import "fmt" | ||
|
||
type Employee struct { | ||
name string | ||
age int | ||
date string | ||
} | ||
|
||
func (e Employee) Getname() string { | ||
return e.name | ||
} | ||
|
||
func (e Employee) Getage() int { | ||
return e.age | ||
} | ||
|
||
func (e Employee) Getdate() string { | ||
return e.date | ||
} | ||
func (e *Employee) SetName(name string) { | ||
e.name = name | ||
} | ||
|
||
func (e *Employee) SetDate(date string) { | ||
e.date = date | ||
} | ||
|
||
func Newemployee(name string, age int, date string) (Employee, error) { | ||
var e Employee = Employee{ | ||
name: name, | ||
date: date, | ||
} | ||
var err = e.SetAge(age) | ||
return e, err | ||
} | ||
|
||
func (e *Employee) SetAge(age int) error { | ||
if age > 17 && age < 80 { | ||
e.age = age | ||
return nil | ||
} | ||
return fmt.Errorf(e.Getname(), "age is incorrect", e.Getdate()) | ||
} |
This file contains 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