Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

05_oop #68

Open
wants to merge 3 commits into
base: lecture-00
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module epamFundamentalN1

go 1.19

require github.com/kyokomi/emoji/v2 v2.2.11 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/kyokomi/emoji/v2 v2.2.11 h1:Pf/ZWVTbnAVkHOLJLWjPxM/FmgyPe+d85cv/OLP5Yus=
github.com/kyokomi/emoji/v2 v2.2.11/go.mod h1:JUcn42DTdsXJo1SWanHh4HKDEyPaR5CqkmoirZZP9qE=
42 changes: 42 additions & 0 deletions solution.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package golang_united_school_homework_1

import (
"fmt"
"reflect"
)

type User struct {
name string
lastName string
}
type UserInterface interface {
SetFirstName(string)
SetLastName(string)
FullName() string
}

func (u *User) SetFirstName(name string) {
u.name = name
}
func (u *User) SetLastName(lastName string) {
u.lastName = lastName
}
func (u *User) FullName() string {
return fmt.Sprintf("%s %s", u.lastName, u.name)
}
func NewUser() User {
return User{}
}
func ResetUser(input *User) {
input.name = ""
input.lastName = ""
}
func IsUser(input any) bool {
if input == nil || reflect.TypeOf(input) != reflect.TypeOf(User{}) {
return false
}
return true
}
func ProcessUser(input UserInterface) string {
return input.FullName()
}