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

Hometask #57

Open
wants to merge 5 commits into
base: 05_oop
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
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module golang-united-school-homework-1

go 1.17
Empty file added go.sum
Empty file.
45 changes: 42 additions & 3 deletions s01.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
package structs

import "fmt"

type UserInterface interface {
SetFirstName(string)
SetLastName(string)
FullName() string
SetFirstName(string)
SetLastName(string)
FullName() string
}

type User struct {
firstName string
lastName string
}

func New() User {
return User{}
}

func (u *User) SetFirstName(firstName string) {
u.firstName = firstName
}

func (u *User) SetLastName(lastName string) {
u.lastName = lastName
}

func (u *User) FullName() string {
return u.lastName + " " + u.firstName
}

func ResetUser(user *User) {
(*user).firstName = ""
(*user).lastName = ""
}

func IsUser(input interface{}) bool {
xType := fmt.Sprintf("%T", input)
accpectType := fmt.Sprintf("%T", User{})
return xType == accpectType
}

func ProcessUser(input UserInterface) string {
input.SetFirstName("Mukhammadkodir")
return input.FullName()
}