Skip to content

Commit

Permalink
adding some punctuation to comments to sort-of fix quii#309
Browse files Browse the repository at this point in the history
  • Loading branch information
quii committed Jun 18, 2020
1 parent 31ce9f7 commit bbc3c8a
Show file tree
Hide file tree
Showing 197 changed files with 655 additions and 655 deletions.
2 changes: 1 addition & 1 deletion arrays/v1/sum.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

// Sum calculates the total from an array of numbers
// Sum calculates the total from an array of numbers.
func Sum(numbers [5]int) int {
sum := 0
for i := 0; i < 5; i++ {
Expand Down
2 changes: 1 addition & 1 deletion arrays/v2/sum.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

// Sum calculates the total from an array of numbers
// Sum calculates the total from an array of numbers.
func Sum(numbers [5]int) int {
sum := 0
for _, number := range numbers {
Expand Down
2 changes: 1 addition & 1 deletion arrays/v3/sum.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

// Sum calculates the total from a slice of numbers
// Sum calculates the total from a slice of numbers.
func Sum(numbers []int) int {
sum := 0
for _, number := range numbers {
Expand Down
4 changes: 2 additions & 2 deletions arrays/v4/sum.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

// Sum calculates the total from a slice of numbers
// Sum calculates the total from a slice of numbers.
func Sum(numbers []int) int {
sum := 0
for _, number := range numbers {
Expand All @@ -9,7 +9,7 @@ func Sum(numbers []int) int {
return sum
}

// SumAll calculates the respective sums of every slice passed in
// SumAll calculates the respective sums of every slice passed in.
func SumAll(numbersToSum ...[]int) []int {
lengthOfNumbers := len(numbersToSum)
sums := make([]int, lengthOfNumbers)
Expand Down
4 changes: 2 additions & 2 deletions arrays/v5/sum.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

// Sum calculates the total from a slice of numbers
// Sum calculates the total from a slice of numbers.
func Sum(numbers []int) int {
sum := 0
for _, number := range numbers {
Expand All @@ -9,7 +9,7 @@ func Sum(numbers []int) int {
return sum
}

// SumAll calculates the respective sums of every slice passed in
// SumAll calculates the respective sums of every slice passed in.
func SumAll(numbersToSum ...[]int) []int {
var sums []int
for _, numbers := range numbersToSum {
Expand Down
4 changes: 2 additions & 2 deletions arrays/v6/sum.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

// Sum calculates the total from a slice of numbers
// Sum calculates the total from a slice of numbers.
func Sum(numbers []int) int {
sum := 0
for _, number := range numbers {
Expand All @@ -9,7 +9,7 @@ func Sum(numbers []int) int {
return sum
}

// SumAllTails calculates the respective sums of every slice passed in
// SumAllTails calculates the respective sums of every slice passed in.
func SumAllTails(numbersToSum ...[]int) []int {
var sums []int
for _, numbers := range numbersToSum {
Expand Down
4 changes: 2 additions & 2 deletions arrays/v7/sum.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

// Sum calculates the total from a slice of numbers
// Sum calculates the total from a slice of numbers.
func Sum(numbers []int) int {
sum := 0
for _, number := range numbers {
Expand All @@ -9,7 +9,7 @@ func Sum(numbers []int) int {
return sum
}

// SumAllTails calculates the sums of all but the first number given a collection of slices
// SumAllTails calculates the sums of all but the first number given a collection of slices.
func SumAllTails(numbersToSum ...[]int) []int {
var sums []int
for _, numbers := range numbersToSum {
Expand Down
10 changes: 5 additions & 5 deletions command-line/v1/file_system_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"sort"
)

// FileSystemPlayerStore stores players in the filesystem
// FileSystemPlayerStore stores players in the filesystem.
type FileSystemPlayerStore struct {
database *json.Encoder
league League
}

// NewFileSystemPlayerStore creates a FileSystemPlayerStore initialising the store if needed
// NewFileSystemPlayerStore creates a FileSystemPlayerStore initialising the store if needed.
func NewFileSystemPlayerStore(file *os.File) (*FileSystemPlayerStore, error) {

err := initialisePlayerDBFile(file)
Expand Down Expand Up @@ -51,15 +51,15 @@ func initialisePlayerDBFile(file *os.File) error {
return nil
}

// GetLeague returns the scores of all the players
// GetLeague returns the scores of all the players.
func (f *FileSystemPlayerStore) GetLeague() League {
sort.Slice(f.league, func(i, j int) bool {
return f.league[i].Wins > f.league[j].Wins
})
return f.league
}

// GetPlayerScore retrieves a player's score
// GetPlayerScore retrieves a player's score.
func (f *FileSystemPlayerStore) GetPlayerScore(name string) int {

player := f.league.Find(name)
Expand All @@ -71,7 +71,7 @@ func (f *FileSystemPlayerStore) GetPlayerScore(name string) int {
return 0
}

// RecordWin will store a win for a player, incrementing wins if already known
// RecordWin will store a win for a player, incrementing wins if already known.
func (f *FileSystemPlayerStore) RecordWin(name string) {
player := f.league.Find(name)

Expand Down
6 changes: 3 additions & 3 deletions command-line/v1/league.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"io"
)

// League stores a collection of players
// League stores a collection of players.
type League []Player

// Find tries to return a player from a league
// Find tries to return a player from a league.
func (l League) Find(name string) *Player {
for i, p := range l {
if p.Name == name {
Expand All @@ -19,7 +19,7 @@ func (l League) Find(name string) *Player {
return nil
}

// NewLeague creates a league from JSON
// NewLeague creates a league from JSON.
func NewLeague(rdr io.Reader) (League, error) {
var league []Player
err := json.NewDecoder(rdr).Decode(&league)
Expand Down
8 changes: 4 additions & 4 deletions command-line/v1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ import (
"net/http"
)

// PlayerStore stores score information about players
// PlayerStore stores score information about players.
type PlayerStore interface {
GetPlayerScore(name string) int
RecordWin(name string)
GetLeague() League
}

// Player stores a name with a number of wins
// Player stores a name with a number of wins.
type Player struct {
Name string
Wins int
}

// PlayerServer is a HTTP interface for player information
// PlayerServer is a HTTP interface for player information.
type PlayerServer struct {
store PlayerStore
http.Handler
}

const jsonContentType = "application/json"

// NewPlayerServer creates a PlayerServer with routing configured
// NewPlayerServer creates a PlayerServer with routing configured.
func NewPlayerServer(store PlayerStore) *PlayerServer {
p := new(PlayerServer)

Expand Down
4 changes: 2 additions & 2 deletions command-line/v2/CLI.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package poker

// CLI helps players through a game of poker
// CLI helps players through a game of poker.
type CLI struct {
playerStore PlayerStore
}

// PlayPoker starts the game
// PlayPoker starts the game.
func (cli *CLI) PlayPoker() {
cli.playerStore.RecordWin("Cleo")
}
10 changes: 5 additions & 5 deletions command-line/v2/file_system_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"sort"
)

// FileSystemPlayerStore stores players in the filesystem
// FileSystemPlayerStore stores players in the filesystem.
type FileSystemPlayerStore struct {
database *json.Encoder
league League
}

// NewFileSystemPlayerStore creates a FileSystemPlayerStore initialising the store if needed
// NewFileSystemPlayerStore creates a FileSystemPlayerStore initialising the store if needed.
func NewFileSystemPlayerStore(file *os.File) (*FileSystemPlayerStore, error) {

err := initialisePlayerDBFile(file)
Expand Down Expand Up @@ -51,15 +51,15 @@ func initialisePlayerDBFile(file *os.File) error {
return nil
}

// GetLeague returns the scores of all the players
// GetLeague returns the scores of all the players.
func (f *FileSystemPlayerStore) GetLeague() League {
sort.Slice(f.league, func(i, j int) bool {
return f.league[i].Wins > f.league[j].Wins
})
return f.league
}

// GetPlayerScore retrieves a player's score
// GetPlayerScore retrieves a player's score.
func (f *FileSystemPlayerStore) GetPlayerScore(name string) int {

player := f.league.Find(name)
Expand All @@ -71,7 +71,7 @@ func (f *FileSystemPlayerStore) GetPlayerScore(name string) int {
return 0
}

// RecordWin will store a win for a player, incrementing wins if already known
// RecordWin will store a win for a player, incrementing wins if already known.
func (f *FileSystemPlayerStore) RecordWin(name string) {
player := f.league.Find(name)

Expand Down
6 changes: 3 additions & 3 deletions command-line/v2/league.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"io"
)

// League stores a collection of players
// League stores a collection of players.
type League []Player

// Find tries to return a player from a league
// Find tries to return a player from a league.
func (l League) Find(name string) *Player {
for i, p := range l {
if p.Name == name {
Expand All @@ -19,7 +19,7 @@ func (l League) Find(name string) *Player {
return nil
}

// NewLeague creates a league from JSON
// NewLeague creates a league from JSON.
func NewLeague(rdr io.Reader) (League, error) {
var league []Player
err := json.NewDecoder(rdr).Decode(&league)
Expand Down
8 changes: 4 additions & 4 deletions command-line/v2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ import (
"net/http"
)

// PlayerStore stores score information about players
// PlayerStore stores score information about players.
type PlayerStore interface {
GetPlayerScore(name string) int
RecordWin(name string)
GetLeague() League
}

// Player stores a name with a number of wins
// Player stores a name with a number of wins.
type Player struct {
Name string
Wins int
}

// PlayerServer is a HTTP interface for player information
// PlayerServer is a HTTP interface for player information.
type PlayerServer struct {
store PlayerStore
http.Handler
}

const jsonContentType = "application/json"

// NewPlayerServer creates a PlayerServer with routing configured
// NewPlayerServer creates a PlayerServer with routing configured.
func NewPlayerServer(store PlayerStore) *PlayerServer {
p := new(PlayerServer)

Expand Down
6 changes: 3 additions & 3 deletions command-line/v3/CLI.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ import (
"strings"
)

// CLI helps players through a game of poker
// CLI helps players through a game of poker.
type CLI struct {
playerStore PlayerStore
in *bufio.Scanner
}

// NewCLI creates a CLI for playing poker
// NewCLI creates a CLI for playing poker.
func NewCLI(store PlayerStore, in io.Reader) *CLI {
return &CLI{
playerStore: store,
in: bufio.NewScanner(in),
}
}

// PlayPoker starts the game
// PlayPoker starts the game.
func (cli *CLI) PlayPoker() {
userInput := cli.readLine()
cli.playerStore.RecordWin(extractWinner(userInput))
Expand Down
12 changes: 6 additions & 6 deletions command-line/v3/file_system_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"sort"
)

// FileSystemPlayerStore stores players in the filesystem
// FileSystemPlayerStore stores players in the filesystem.
type FileSystemPlayerStore struct {
database *json.Encoder
league League
}

// NewFileSystemPlayerStore creates a FileSystemPlayerStore initialising the store if needed
// NewFileSystemPlayerStore creates a FileSystemPlayerStore initialising the store if needed.
func NewFileSystemPlayerStore(file *os.File) (*FileSystemPlayerStore, error) {

err := initialisePlayerDBFile(file)
Expand All @@ -34,7 +34,7 @@ func NewFileSystemPlayerStore(file *os.File) (*FileSystemPlayerStore, error) {
}, nil
}

// FileSystemPlayerStoreFromFile creates a PlayerStore from the contents of a JSON file found at path
// FileSystemPlayerStoreFromFile creates a PlayerStore from the contents of a JSON file found at path.
func FileSystemPlayerStoreFromFile(path string) (*FileSystemPlayerStore, func(), error) {
db, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0666)

Expand Down Expand Up @@ -72,15 +72,15 @@ func initialisePlayerDBFile(file *os.File) error {
return nil
}

// GetLeague returns the scores of all the players
// GetLeague returns the scores of all the players.
func (f *FileSystemPlayerStore) GetLeague() League {
sort.Slice(f.league, func(i, j int) bool {
return f.league[i].Wins > f.league[j].Wins
})
return f.league
}

// GetPlayerScore retrieves a player's score
// GetPlayerScore retrieves a player's score.
func (f *FileSystemPlayerStore) GetPlayerScore(name string) int {

player := f.league.Find(name)
Expand All @@ -92,7 +92,7 @@ func (f *FileSystemPlayerStore) GetPlayerScore(name string) int {
return 0
}

// RecordWin will store a win for a player, incrementing wins if already known
// RecordWin will store a win for a player, incrementing wins if already known.
func (f *FileSystemPlayerStore) RecordWin(name string) {
player := f.league.Find(name)

Expand Down
Loading

0 comments on commit bbc3c8a

Please sign in to comment.