game

package
v0.0.0-...-31f7bde Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2016 License: Apache-2.0 Imports: 0 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	// contains filtered or unexported fields
}

Game represents a cowbull game.

func New

func New(thinker Thinker, guesser Guesser) *Game

NewGame creates new gime with the provided players.

func (*Game) Play

func (g *Game) Play() error

Play plays the game with the players.

type Guesser

type Guesser interface {
	// Guess should return a guess number consisting of n digits.
	Guess(n int) (string, error)
	// Tell should tell the player the result of his guess.
	Tell(string, int, int) error
}

Guesser represents a player that tries to guess a number.

type Thinker

type Thinker interface {
	// Number makes the player to think of a number and returns the count of
	// its digits.
	Think() (int, error)
	// Try should return the cows and bulls in the specified number.
	// If the number's digit count is not equal to the one returned by Number,
	// the player should return (0, 0).
	Try(string) (cows int, bulls int, err error)
}

Thinker represents a player that thinks of a number and answers questions about it.

Directories

Path Synopsis
This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL