Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2016 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b3ff5dd00bef5991dbf6f617122d0eb4 to your computer and use it in GitHub Desktop.
Save anonymous/b3ff5dd00bef5991dbf6f617122d0eb4 to your computer and use it in GitHub Desktop.
module Menu
def menu
" Welcome to the TodoList Program!
This menu will help you use the Task List System
1) Add
2) Show
Q) Quit "
end
def show
menu
end
end
module Promptable
def prompt(message = "what would you like to do ?", symbol = ":!!!")
print message
print symbol
gets.chomp
end
end
class List
attr_reader :all_tasks
def initialize
@all_tasks = []
end
def add(task)
@all_tasks << task
end
def show_list
@all_tasks.each do |task|
task
end
end
end
class Task
attr_reader :description
def initialize(description)
@description = description
end
def to_s
description.to_s
end
end
if __FILE__ == $0
include Menu
include Promptable
my_list = List.new
puts "please choose from the following list:"
user_input = gets.chomp
until user_input == "q" do prompt(show)
end
puts 'You have created a new list'
my_list.add(Task.new('Make Breakfast'))
my_list.add(Task.new('Go to the cinema'))
puts 'You have added a task to the Todo List'
puts "and here you can see all your task"
puts my_list.show_list
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment