Last active
December 20, 2015 02:09
-
-
Save yucao24hours/6054328 to your computer and use it in GitHub Desktop.
1. 耳の遠いおばあちゃんのプログラムを書いてみましょう。 おばあちゃんに何を言っても(何をタイプしても)、叫ばない限り (つまり、全部大文字でタイプしない限り)、 は?! もっと大きな声で話しておくれ、坊や! と返事をします。もし叫んだときは、彼女はあなたの言葉を聞いて (少なくとも聞いた気がして)、 いやー、1938年以来ないねー! と大声で返事をします。 プログラムにちょっと真実味 を持たせるため、 1930年から1950年のランダムな数字で毎回違う年を叫ぶようにしましょう。
2. 上で作った、「耳の遠いおばあちゃんのプログラム」を拡張しましょう。 おばあちゃんはあなたに行って欲しくないのです。 あなたがBYEと叫んでもおばあちゃんは聞こえないふりをします。 BYEを3回連続で …
This file contains hidden or 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
| puts 'Hello! May I help you?' | |
| word = gets.chomp | |
| while word != 'BYE' | |
| if word.upcase == word | |
| puts 'Well, it hasn\'t happened since ' + (1930 + rand(21)).to_s + ' !' | |
| else | |
| puts 'Huh? Could you speak up, please??' | |
| end | |
| word = gets.chomp | |
| end | |
| puts 'Thanks. Come back anytime.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BYEは3回がんばれ 👵