Sha256: 61f6e53208bf19c9986c2482e67bdf3738cbdaa95e167333a0648f724cc55ecf

Contents?: true

Size: 844 Bytes

Versions: 78

Compression:

Stored size: 844 Bytes

Contents

package clock

import "fmt"

func ExampleClock_new() {
	// a new clock
	clock1 := New(10, 30)
	fmt.Println(clock1.String())

	// Output: 10:30
}

func ExampleClock_Add() {
	// create a clock
	clock := New(10, 30)

	// add 30 minutes to it
	clock = clock.Add(30)
	fmt.Println(clock.String())

	// Output: 11:00
}

func ExampleClock_Subtract() {
	// create a clock
	clock := New(10, 30)

	// subtract an hour and a half from it
	clock = clock.Subtract(90)
	fmt.Println(clock.String())

	// Output: 09:00
}

func ExampleClock_compare() {
	// a new clock
	clock1 := New(10, 30)

	// a second clock, same as the first
	clock2 := New(10, 30)

	// are the clocks equal?
	fmt.Println(clock2 == clock1)

	// change the second clock
	clock2 = clock2.Add(30)

	// are the clocks equal now?
	fmt.Println(clock2 == clock1)

	// Output:
	// true
	// false
}

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.179 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.178 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.177 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.176 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.175 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.174 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.173 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.172 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.171 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.170 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.169 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.167 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.166 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.165 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.164 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.163 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.162 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.161 tracks/go/exercises/clock/example_clock_test.go
trackler-2.2.1.160 tracks/go/exercises/clock/example_clock_test.go