+ 2

help solve Golang Ticking timer project solution

package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} var a int //results = append (results, results[(len(results)-1)]) results = append (results, results[0]) for _, v := range results { switch { case v == "w": a += 3 case v == "l": a += 0 case v == "d": a += 1 } } fmt.Println(a) }

24th Jun 2021, 10:19 AM
Samson Nyachani Otweka
6 Respostas
+ 13
package main import "fmt" /* Define a Timer struct with two fields: id and value */ type Timer struct { id string value int } /* define the tick() method, which should increment the value by one and output its current value. */ func (t *Timer) tick() { for i := 0; i < t.value; i++ { fmt.Println(i + 1) } } func main() { var x int fmt.Scanln(&x) t := Timer{"timer1", x} t.tick() }
2nd Jul 2021, 3:50 PM
DaReaper
DaReaper - avatar
+ 5
Lothar Samson Nyachani Otweka Solution of ticking Timer using Go Language. package main import "fmt" type Timer struct{ id string value int } func (ptr *Timer) tick() { ptr.value += 1 fmt.Println(ptr.value) } func main() { var x int fmt.Scanln(&x) t := Timer{"timer1", 0} for i:=0;i<x;i++ { t.tick() } }
27th Jul 2021, 8:47 AM
Younes Damouna
Younes Damouna - avatar
+ 2
Samson Nyachani Otweka , this post looks a bit weird for me. the title of your post says: "help solve Golang Tjcking timer project solution", but the code you provided is from the "Match" project. there is also a task description missing.
24th Jun 2021, 2:02 PM
Lothar
Lothar - avatar
+ 1
package main import "fmt" type Timer struct{ id string value int } func (s *Timer)tick(){ s.value+=1 fmt.Println(s.value) } func main() { var x int fmt.Scanln(&x) t := Timer{"timer1", 0} for i:=0;i<x;i++ { t.tick() } }
6th Dec 2022, 12:53 AM
Samba Sy
Samba Sy - avatar
0
Lothar Samson Nyachani Otweka Solution of ticking Timer using Go Language. package main import "fmt" type Timer struct{ id string value int } func (ptr *Timer) tick() { ptr.value += 1 fmt.Println(ptr.value) } func main() { var x int fmt.Scanln(&x) t := Timer{"timer1", 0} for i:=0;i<x;i++ { t.tick() } }
27th Jul 2021, 8:47 AM
Younes Damouna
Younes Damouna - avatar
0
package main import "fmt" type Timer struct{ id string value int } func (ptr *Timer) tick() { ptr.value += 1 fmt.Println(ptr.value) } func main() { var x int fmt.Scanln(&x) t := Timer{"timer1", 0} for i:=0;i<x;i++ { t.tick() } }
18th Sep 2022, 6:37 AM
Kanisak Shakya
Kanisak Shakya - avatar