Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panda & Tiger level completed #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Panda & Tiger level completed #21

wants to merge 5 commits into from

Conversation

ardder
Copy link

@ardder ardder commented Jul 15, 2013

No description provided.

puts "-" * 80
puts "Which week day do you want watch TV shows?"
puts "1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday, 7: Sunday or Q: Quit"
STDOUT.write "Select a day [1~7 or Q]:"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably recommend to either stick with puts or STDOUT.

@jwo
Copy link
Member

jwo commented Jul 15, 2013

Great job! Only stylistic points to mention. yay!

I keep thinking about this line:

puts "1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday, 7: Sunday or Q: Quit"

It's not bad --- but it does repeat some information. Like the WEEK_DAY above as a constant. I might do something like:

COMMANDS = {"Q" => "Quit"} 
all_choices = WEEK_DAY.merge(COMMANDS)
puts all_choices.map{ |k,v| "#{k}: #{v}"}.join(" or ")

Then later, you could do something like

day = select_day

if all_choices[day].nil?
  puts "invalid choice #{day}, please try again"
  next
end

Unsure if that really makes it better not, but wanted to show an alternate flow.

@ardder
Copy link
Author

ardder commented Jul 16, 2013

I think you are right. I especially like all_choice[day].nil?. It can replace my ugly regex!

BTW, I also finished the assignment of Episode 2. Can you check my code?

Thanks, @jwo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants