<repo_name>glowingmoth/AlphabetForKids<file_sep>/src/Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"

#gem "ruby2d", "~> 0.9.4"

#gem "ascii-image", "~> 0.1.5"

#gem "rmagick", "~> 2.16"

gem "colorize", "~> 0.8.1"

<file_sep>/docs/HelpFile.md
# Instructions - Alphabet for Kids

1. Download current repository
2. Install Ruby.
https://www.ruby-lang.org/en/downloads/

3. In the terminal navigate to the src directory within the downloaded repository type: ./play.sh and hit Enter. Make sure to maximize the terminal window if text  Title screen looks broken.

4. User will be presented with menu screen containing the  following options
- **Sight Words** [Press 1 & hit Enter]
- **Missing Letter** [Press 2 & hit Enter]
- **Exit** [Press 3 & hit Enter]



4. When the parent enters Sight Words it will enter a mode of allowing a the child to press a single **[letter]** that displays the **[letter]** pressed and a word it's for. Pressing the **[3]** key will exit back to the menu.

5. When the parent enters Missing Letter mode the child will be able to press a **[letter]** and and the app will display the **[letter]** and the word with a random missing letter. The child will have 3 attempts to guess the letter. After **[3]** attempts it will let the child choose another letter for a new word. Pressing the **[3]** key will exit back to the menu.

6. If the parent presses **[3]** and **[Enter]** they will exit the program.

## Known Issues:

There is an issue with the key presses when in the sight words or missing letter modes.

holding the key down or pressing it before the ascii art disappears will cause the app to work through every key press, causing a back log.

The work around/temp fix If you don't want to wait for each press to be executed is to press ctrl + c. This will exit the app, then you can ./play.sh to run it again.
<file_sep>/src/tests.rb
require 'test/unit'
require_relative './ascii_art'
require 'colorize'


# Nested hash holding both alphabet categories
$words_hash = {
    'A' => {animal: 'Ant', object: 'Apple'},
    'B' => {animal: 'Bird', object: 'Bus'},
    'C' => {animal: 'Cat', object: 'Castle'},
    'D' => {animal: 'Dog', object: 'Drums'},
    'E' => {animal: 'Elephant', object: 'Earmuffs'},
    'F' => {animal: 'Fish', object: 'Flowers'},
    'G' => {animal: 'Goat', object: 'Guitar'},
    'H' => {animal: 'Horse', object: 'Helicopter'},
    'I' => {animal: 'Impala', object: 'Igloo'},
    'J' => {animal: 'Jellyfish', object: 'Jeep'},
    'K' => {animal: 'Kangaroo', object: 'Key'},
    'L' => {animal: 'Lion', object: 'Ladder'},
    'M' => {animal: 'Mouse', object: 'Moon'},
    'N' => {animal: 'Numbat', object: 'Nest'},
    'O' => {animal: 'Octopus', object: 'Orange'},
    'P' => {animal: 'Pig', object: 'Planet'},
    'Q' => {animal: 'Quail', object: 'Queen'},
    'R' => {animal: 'Rabbit', object: 'Ring'},
    'S' => {animal: 'Snake', object: 'Scissors'},
    'T' => {animal: 'Turtle', object: 'Tree'},
    'U' => {animal: 'Urchin', object: 'Umbrella'},
    'V' => {animal: 'Vulture', object: 'Violin'},
    'W' => {animal: 'Whale', object: 'Watch'},
    'X' => {animal: 'Xerus', object: 'X-ray'},
    'Y' => {animal: 'Yak', object: 'Yoyo'},
    'Z' => {animal: 'Zebra', object: 'Zip'}
}


class AppTest < Test::Unit::TestCase
    def test_hash_value
        assert_equal($words_hash['N'][:animal],'Numbat')
    end

    def test_apple
        assert_equal( apple, "

                                                                      ,*/.
                                                            (&  .((((((((###%%%.
                                                            %.,////((((###########.
                                                            %    ********/((((((//(#
                                                    (%%##%###%(/((#%#//****/(#(#(/*,(
                                                (%%#%%%#%*,**(##%#********/(/,.
                                              %&%%%%#/**/#%#/*,,,......,#%%%%##
                                            %&&&&&&%##(##((/,,,,,,,,,,.,,*%%%%%%.
                                          &&&&&&&%&%%%%%%%%#((###%%%%%%#%%&%%&%%*
                                          &&&&&&&&&&&&&&&%&&&%&&&%&%%%&&%%%%%%%%%%
                                        /@@&&&&&&&&&&&&&&&&&&&&&&%&%&&%&%%#%%%%%%*
                                        %&&&&&&&&&&&&&&&&&&%&&&&&&&&&&%%%%###%%%%*
                                        #&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%%%%%%%%%%
                                          &&&%%%&&&&%&&&&&&&&%&%&&&%&%%%%%%%%%%#(#
                                          ,((##%%%%#%&&&&&&&&&%%%&%%%%%%#%#%##((/
                                          *((###%%%%%%%%&%&&%%%%%%%%%%#####((/*
                                            *(##%%%%%%%#%%#%#%%%%%%%#%(####((/*
                                            .%%%%%%%%%%%%%%%%%%%%%######(#(/
                                              /%&&&&&&&&&%%%%#%%%%%%###((//,
                                              %%%&&&&&&&&%%%%%%%(##(##((*.
                                                ##%%&&&&&&&&%%&%%&&&%%#/,.
                                                .,,***///((((/*,....".colorize(:red))
    end


end

<file_sep>/src/alphabet_for_kids.rb
require 'tty-cursor'
require 'colorize'
require_relative 'ascii_art'

#Title Screen
def title
    system('clear')
    puts ""
    puts ""
    puts "
                        ____ _    ___  _  _ ____ ___  ____ ___    ____ ____ ____   _  _ _ ___  ____
                        |__| |    |__] |__| |__| |__] |___  |     |___ |  | |__/   |_/  | |  \\ [__
                        |  | |___ |    |  | |  | |__] |___  |     |    |__| |  \\   |\\_  | |__/ ___]".colorize(:cyan)

    puts ""
    puts ""
    puts "                                          Choose an option and press Enter:"
    puts ""
    puts "                                                   1 = Sight Words".colorize(:light_blue)
    puts "                                                   2 = Missing Letter".colorize(:light_red)
    puts "                                                   3 = Exit".colorize(:green)
end



  #This is for fetching the letter pressed and randomly choosing from either category
  def missing(letter, image)

    #Random number to choose either category
    category = rand(1..2)
    if category == 1
      category = :animal
    elsif category == 2
      category = :object
    end

    #This prints a message if any key pressed other than a letter or Exit [3]
    unless $words_hash.key?(letter)
        puts "no match"
    else
        selected_word = $words_hash[letter][category]
        arry_m_letter = selected_word.split("")

        num = arry_m_letter.length
        num -= 1

        # the random index number for removing a letter
        fn = rand(0..num)

        # returns the letter at the random index and puts in m_l
        $m_l = arry_m_letter[fn]

        # deletes the letter at the random index
        arry_m_letter.delete_at(fn)

        # replace the deleted letter with an empty space
        arry_m_letter.insert(fn,"_")

        # convert back into a string
        new_word = arry_m_letter.join("").capitalize
        sleep(2)
        puts ""
        puts ""
        puts ""
        puts "                                                 #{letter} is for #{new_word}"
        puts ""
        puts ""
        puts image[letter][category]


    end
        #sleep(1)
  end

  #This fetches the key pressed and randomly removes a letter from the word
  def is_for(letter, image)


    #Random number to choose either category
    category = rand(1..2)
    if category == 1
        category = :animal
    elsif category == 2
        category = :object
    end

    #This prints a message if any key pressed other than a letter or exit [3]
    unless $words_hash.key?(letter)
        puts "no match"
    else
      # system("clear")
      # sleep(1)
      # rabbit
      # sleep(2)
      puts ""
      puts ""
      puts "                                                    #{letter} is for #{$words_hash[letter][category]}"
      puts ""
      puts ""
      puts image[letter][category]
    end
    return
  end
# Nested hash holding both alphabet categories
$words_hash = {
    'A' => {animal: 'Ant', object: 'Apple'},
    'B' => {animal: 'Bird', object: 'Bus'},
    'C' => {animal: 'Cat', object: 'Castle'},
    'D' => {animal: 'Dog', object: 'Drums'},
    'E' => {animal: 'Elephant', object: 'Earmuffs'},
    'F' => {animal: 'Fish', object: 'Flowers'},
    'G' => {animal: 'Goat', object: 'Guitar'},
    'H' => {animal: 'Horse', object: 'Helicopter'},
    'I' => {animal: 'Impala', object: 'Igloo'},
    'J' => {animal: 'Jellyfish', object: 'Jeep'},
    'K' => {animal: 'Kangaroo', object: 'Key'},
    'L' => {animal: 'Lion', object: 'Ladder'},
    'M' => {animal: 'Mouse', object: 'Moon'},
    'N' => {animal: 'Numbat', object: 'Nest'},
    'O' => {animal: 'Octopus', object: 'Orange'},
    'P' => {animal: 'Pig', object: 'Planet'},
    'Q' => {animal: 'Quail', object: 'Queen'},
    'R' => {animal: 'Rabbit', object: 'Ring'},
    'S' => {animal: 'Snake', object: 'Scissors'},
    'T' => {animal: 'Turtle', object: 'Tree'},
    'U' => {animal: 'Urchin', object: 'Umbrella'},
    'V' => {animal: 'Vulture', object: 'Violin'},
    'W' => {animal: 'Whale', object: 'Watch'},
    'X' => {animal: 'Xerus', object: 'X-ray'},
    'Y' => {animal: 'Yak', object: 'Yoyo'},
    'Z' => {animal: 'Zebra', object: 'Zip'}
}
# Ascii art hash
image = {}
image["A"] = {}
image["A"][:object] = apple
image["A"][:animal] = ant
image["B"]= {}
image["B"][:object]= bus
image["B"][:animal] = bird
image["C"] = {}
image["C"][:object] = castle
image["C"][:animal] = cat
image["D"] = {}
image["D"][:object] = drums
image["D"][:animal] = dog
image["E"] = {}
image["E"][:object] = earmuffs
image["E"][:animal] = elephant
image["F"] = {}
image["F"][:object] = flowers
image["F"][:animal] = fish
image["G"] = {}
image["G"][:object] = guitar
image["G"][:animal] = goat
image["H"] = {}
image["H"][:object] = helicopter
image["H"][:animal] = horse
image["I"] = {}
image["I"][:object] = igloo
image["I"][:animal] = impala
image["J"] = {}
image["J"][:object] = jeep
image["J"][:animal] = jellyfish
image["K"] = {}
image["K"][:object] = key
image["K"][:animal] = kangaroo
image["L"] = {}
image["L"][:object] = ladder
image["L"][:animal] = lion
image["M"] = {}
image["M"][:object] = moon
image["M"][:animal] = mouse
image["N"] = {}
image["N"][:object] = nest
image["N"][:animal] = numbat
image["O"] = {}
image["O"][:object] = orange
image["O"][:animal] = octopus
image["P"] = {}
image["P"][:object] = planet
image["P"][:animal] = pig
image["Q"] = {}
image["Q"][:object] = queen
image["Q"][:animal] = quail
image["R"] = {}
image["R"][:object] = ring
image["R"][:animal] = rabbit
image["S"] = {}
image["S"][:object] = scissors
image["S"][:animal] = snake
image["T"] = {}
image["T"][:object] = tree
image["T"][:animal] = turtle
image["U"] = {}
image["U"][:object] = umbrella
image["U"][:animal] = urchin
image["V"] = {}
image["V"][:object] = violin
image["V"][:animal] = vulture
image["W"] = {}
image["W"][:object] = watch
image["W"][:animal] = whale
image["X"] = {}
image["X"][:object] = xray
image["X"][:animal] = xerus
image["Y"] = {}
image["Y"][:object] = yoyo
image["Y"][:animal] = yak
image["Z"] = {}
image["Z"][:object] = zip
image["Z"][:animal] = zebra


#Main menu loop
while true
    #Run the title screen method
    title
    options = gets.chomp
    case options
    when '1'
        #Loop for Sight Words option
        while true
            system('clear')
            puts ""
            puts ""
            puts "(Press 3 to Exit)                               Press a letter to begin! "
            #Get key press without having to press enter key after
            begin
                system('stty raw -echo') #This terminal/system command wil
                key = STDIN.getc #Using I/O to get key press and convert to string
                system("stty -raw echo")
                if key == "3"
                    break
                end
                letter = key.upcase
                #Method for grabbing letter pressed by user

                is_for(letter, image)
                sleep(4)
            ensure
                system("stty -raw echo")
            end
        end
    when '2'
        #Loop for the Missing Letter option
        while true
            system('clear')
            puts ""
            puts ""
            puts "(Press 3 to Exit)                                    Guess the missing letter!"
            begin
                system('stty raw -echo') #This terminal/system command wil
                first_key = STDIN.getc #Using I/O to get key press and convert to string
                system('stty -raw echo') #This terminal/system command wil
                if first_key == "3"
                    break
                end

                correct_letter_attempts = 0
                while correct_letter_attempts <= 3
                    game_letter = first_key.upcase
                    #Method for grabbing letter pressed by user
                    #is_for(letter)
                    missing(game_letter, image)
                    begin
                        system('stty raw -echo') #This terminal/system command wil
                        answer_key = STDIN.getc #Using I/O to get key press and convert to string
                        system('stty -raw echo') #This terminal/system command wil
                        if answer_key == $m_l
                            system('clear')
                            puts ""
                            puts ""
                            puts "                                                       Correct!".colorize(:light_blue)
                            sleep(1)
                            break
                        elsif answer_key != $m_l
                            system('clear')
                            puts ""
                            puts ""
                            puts "                                                       Try Again".colorize(:light_red)
                            sleep(0.5)
                            break
                        elsif answer_key == '3'
                            break
                        end
                        correct_letter_attempts += 1
                    ensure
                        system("stty -raw echo")
                    end
                end
            ensure
                system("stty -raw echo")
            end
        end
    # Exiting the App
    when '3'
        system('clear')
        puts ""
        puts ""
        puts "                                               Thank you for using ALPHABET for KIDS!".colorize(:cyan)
        puts ""
        puts ""
        sleep(1)
        exit
    end
end

























<file_sep>/README.md

### R4 - **Provide a link to your source control repository**
https://github.com/glowingmoth/AlphabetForKids

### R5 - **Statement of Purpose and Scope**
Being a father of two young children  I'm aware that early education is vital for their development.
- The app is for learning the alphabet and basic spelling.
- The target audience is for the ages between 5-8, however this may vary slightly as each child is different.
- Learning that is fun and that can engage is always better and in the case of children, this app was no exception.
- The app will have a main menu where the child (or parent) can choose between 1 of two options. Choosing any letter on the keyboard will allow them to see a word from either category of animals or objects. There is a slightly more advanced options where instead of showing a complete word relating to the chosen letter, it will remove a random letter from the word and give them the options to guess what letter is missing.

### R6 - **Features**
- **Archive of words** - The app has 52 words for children to learn through 2 categories available ie. animals and objects. Essentially these are sight words and when presented repeatedly with the letter that is pressed the child will be able to see how the first letter is at the beginning and related to the word.
- **Guidance** - The app is designed for children and so has to be as simple as possible. To accomplish this, the app will not require the child to do anything after it receives input, instead the app will go back to the  menu and allow them to press another letter.
- **Missing Letters** - For children needing slightly more challenging learning, there is the ability to choose the missing letter option of the app. The child presses any letter on the keyboard and this time instead of showing the complete word it will show the word from either category ie, animals or objects and removes a random letter.

    If the child where to press the same letter again (after being back at the start of the missing letter option) a different letter would be missing. This means the **missing letter isn't hard coded** and the child can't get the letter right purely by memory.
- **Ascii images/art** - Images are the universal language and so they're a MUST when trying to create a fun learning experience for children. The MVP is purely text based however the implementation of images/ascii would greatly enhance the boring environment that is the terminal, especially in the context of a child user. There are 52 words and to accompany these words, 52 different pieces of ascii art
- **Animations** - The next step up from images in the same category would be animations. Due to the nature of the terminal this feature will be a bonus and implemented last, if there is still enough time. Otherwise this can be added after the due date.

### R7 - **User Interaction & Experience**
- **How to Interact** Dealing with an age (in the case of no parent to supervise) that is still learning to read, things need to be shown visually with images/pictures or be intuitive. For this reason the child will essentially learn how to interact by pressing keys on the key board.
- **Interaction** By pressing any letter on the key board the child can choose whatever letter they like and see a word and art relating to that letter.
- **Errors** will be handled in a simplified way from the child's perspective, however still informing a parent of the wrong key or letter being pressed. The app will simply ignore any keys pressed that are not letters or numbers in the case of the main menu loop.

### R9 - **Implementation Plan**
https://github.com/glowingmoth/AlphabetForKids/blob/master/docs/ControlFlow_AlphabetKids.png
- With the idea in mind I needed to get a clear image of the program logic and so created a flow chart to flesh out any unforeseen issues. This proved to be very useful as I actually recognized several issue immediately once I could see them. The flowchart proved invaluable through the early to mid stages of development.
https://github.com/glowingmoth/AlphabetForKids/blob/master/docs/Trello_7.png
- Having never used any project management system such as Agile and Trello there was some learning and experience to gain. But I can really see the benefit now. My use in the future, now that I have some experience, will be to add more check lists, as I wasn't aware of them and kept creating new cards instead of adding a check list to what was already there.

- From this point , with my limited understanding or perhaps brain jammed full of information from the past to weeks of the bootcamp I decided to go with a hash to store the alphabet, words and categories as I still lacked in understand all the features of using classes and inheritance. 
- To store the ascii art and call them later I placed the strings inside methods which may not have been the best choice. I separated the files and had the rest of the source code ie. methods with main while loops, hashes etc in the main.rb file (now renamed).
- In conclusion, I truly did my best to incorporate everything I had learnt from my instructors. Whilst not following best practices/coding conventions everywhere I still managed to clean up as much of the source code with what damage had all ready been done. If I were to attempt this again, I would most definitely plan and flesh out on paper how to structure the code.

<file_sep>/src/play.sh
bundle install
ruby ../src/alphabet_for_kids.rb