Created
September 17, 2018 02:12
-
-
Save cwu159/6ceee5f051cff583406bb4a634c6e948 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DataStructures | |
println("Periodic Table Practice \t made by Charlie Wu, 2018 \t using JuliaLang") | |
user_input = "" | |
elements = Dict{String, String}() | |
if length(ARGS) > 0 | |
load_file = open(ARGS[1]) | |
else | |
load_file = open("elements.txt") | |
end | |
lines = readlines(load_file) | |
for line in lines | |
parts = split(line, " ") | |
elements[parts[1]] = parts[2] | |
end | |
while lowercase(user_input) != "quit" | |
current_element = rand(elements) | |
println(current_element[1]) | |
global user_input | |
user_input = readline(stdin) | |
if lowercase(user_input) == current_element[2] | |
println("Correct!") | |
else | |
println("Incorrect.") | |
end | |
println("-"^10) | |
end | |
println("Thanks for using Periodic Table Practice!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment