flashcards

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//CARDFRONT template for the front of the card
	CARDFRONT = "Card front:\n{{.Front}}\n\n\n"
	//CARDBACK template for the back of the card
	CARDBACK = "Card back:\n{{.Back}}\n\n\n"
	//CARDHINT template for the card hint
	CARDHINT = "Card hint:\n{{.Hint}}\n\n\n"
	//HELPTEXT shows the commands
	HELPTEXT = "\n\n(n)ext (p)revious (f)lip (h)int (q)uit\n"
	//COUNTERTEXT template for card counter text
	COUNTERTEXT = "Count: %d/%d\n"
	//USERINPUTTEXT the template for taking in the user input
	USERINPUTTEXT = "\nUser input: "
	//RANDOMCARD used for the random card app
	RANDOMCARD = "Name: {{.Front}} ({{.Back}}) -- {{.Hint}}\n"
	//GROUPCARD used for the group card app
	GROUPCARD = "{{.Front}} ({{.Back}}) -- {{.Hint}}\n"
)

Variables

This section is empty.

Functions

func BreakLoop

func BreakLoop(input string) bool

BreakLoop handles the cases that break the loop

func CardSelectCounter

func CardSelectCounter(input string, count int) int

CardSelectCounter use to increment and decrement the card counter

func Clear

func Clear()

Clear clears the screen.

func CreateCards

func CreateCards(fileName string, dest *[]Card)

CreateCards created the flashcards

func CreateTemplate

func CreateTemplate(name, words string) *template.Template

CreateTemplate is responsible for creating the templates

func FlashcardApp

func FlashcardApp(cards FlashCards, shuffle bool)

FlashcardApp is used to run the terminal flashcard app

func InSlice

func InSlice(slice []string, s string) bool

InSlice used to check of string is in slice

func InputCardFace

func InputCardFace(input string) string

InputCardFace used to figure out what part of the card the user wants to see

func PrintToScreen

func PrintToScreen(templ *template.Template, data interface{}, w io.Writer)

PrintToScreen prints templates to standard out

func TemplateString

func TemplateString(c *Card, face string) *template.Template

TemplateString used to create the correct card template output

Types

type Card

type Card struct {
	Front   string `csv:"front"`
	Back    string `csv:"back"`
	Hint    string `csv:"hint"`
	Flipped bool
}

Card is a struct to represent a single flash card

func (*Card) Flip

func (c *Card) Flip()

Flip tracks the flipped state of the card

type Cards

type Cards struct {
	Cards []Card
}

Cards is a data structure to hold all of the flash cards

func (Cards) GetCards

func (c Cards) GetCards() []Card

GetCards returns the cards

func (Cards) Shuffle

func (c Cards) Shuffle()

Shuffle shuffles the cards in place

type FlashCards

type FlashCards interface {
	GetCards() []Card
	Shuffle()
}

FlashCards testing

Jump to

Keyboard shortcuts

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