Skip to content

Commit

Permalink
Create person and say hi
Browse files Browse the repository at this point in the history
  • Loading branch information
gagarinfan committed Dec 12, 2018
1 parent 1161ed8 commit 5007ffd
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/people.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package main

import (
"bufio"
"fmt"
"os"
"strings"
)

type Person struct {
Expand All @@ -13,25 +10,39 @@ type Person struct {
age int
hobby string
active bool
id int
id string
}

type people interface {
Describe() string
type People interface {
GetName() string
}

func createUser(name, surname, hobby string, age, id int, active bool) *Person {
return &Person()
func createUser(name, surname, hobby, id string, age int, active bool) *Person {
return &Person{name: name, surname: surname, age: age, hobby: hobby, active: active, id: id}
}

func getUsername(s string) {
fmt.Printf("Hi %v, how are you?\n", s)
func (p *Person) GetName() string {
return (p.name + " " + p.surname)
}

func describe(p People) {
fmt.Println("Hi", p.GetName())
}

func main() {
reader := bufio.NewReader(os.Stdin)
//var map = make(map[string]Person)

fmt.Println("Insert your data here:")
name, _ := reader.ReadString('\n')
name = strings.Replace(name, "\n", "", -1)
getUsername(name)
var name, surname, hobby string
var age int
fmt.Scanln(&name)
fmt.Scanln(&surname)
fmt.Scanln(&age)
fmt.Scanln(&hobby)
active := true
id := "100" //for now let it be hardcoded

newMan := createUser(name, surname, hobby, id, age, active)
describe(newMan)

}

0 comments on commit 5007ffd

Please sign in to comment.