Newer
Older
Ruby / toi.rb
@NARITA Reo NARITA Reo on 16 Mar 2022 585 bytes 2022-03-16 21:03:32
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

name=[]
explanation=[]

i=0

menu=Hash.new

while true
  puts("おもちゃの名前を入力してください。")
  name=gets.chomp
  puts("おもちゃの説明を入力してください")
  explanation=gets.chomp
  menu[name]=explanation
  puts("他にもおもちゃを追加しますか(y/n)。")
  answer=gets.chomp
  if answer=="n"
    break
  end
end

p menu

for i,j in menu
  printf("%s:%s\n",i,j)
end
puts("上の中でどれを買いたいですか。")
toianswer=gets.chomp
printf("%sは売り切れです。\n",toianswer)