1. Dan Carroll
  2. FlashCards

Source

FlashCards / FlashCards / WordSet.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FlashCards
{
    class WordSet
    {
        private int pos = -1;

        public WordSet(string name)
        {
            this.Name = name;
            this.Words = new List<Word>();
        }

        public string Name { get; set; }
        public List<Word> Words { get; private set; }

        public void AddWord(string name, string definition)
        {
            this.Words.Add(new Word(name, definition));
        }

        public Word GetNextWord()
        {
            this.pos++;

            if (this.pos >= this.Words.Count)
            {
                this.pos = 0;
            }

            return this.Words[this.pos];
        }

        public Word GetPreviousWord()
        {
            this.pos--;

            if (this.pos < 0)
            {
                this.pos = this.Words.Count - 1;
            }

            return this.Words[this.pos];
        }
    }
}