+ 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) }
6 Antworten
+ 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()
}
+ 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()
}
}
+ 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.
+ 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()
}
}
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()
}
}
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()
}
}