0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ターミナル上で体重を記録するアプリを作成。skillhacks学習記録。

Posted at

skillhacksのRubyメモアプリを自分で改造

今回は迫さんが提供している「Skill Hacks」の学習記録です。 とりあえずコーポレートサイト以外の章を一周したので、第6章で課題にされているターミナル上で動くメモアプリをほぼ何も見ないで再現し、かつちょっと改造しました。

ソースコードはこちら

     def write_log
        puts "日付を入力してください"
        day = gets.chomp
        puts "体重を入力して"
        weight = gets.chomp
        
        date = {"日付"=>day,"体重"=>weight}
    end
    
    def show(dates)
        puts "記録を確認する"
        dates.each do |date|
            puts date["日付"] +":"+ date["体重"]
        end
    end
    

dates = []

puts "---------------"

while true

puts "モードを選択して"
puts "【add】で新規作成"
puts "【show】で全記録をみる"

mode = gets.chomp

    if mode == "add"
    dates.push(write_log)
    
    elsif mode == "show"
    show(dates)
    
    else
    puts "エラーです"
    end
end

感想

制作時間は15分くらいです。ruby基礎と情報発信をかねて今回の記事を作ったので全く良い作品ではないと思います(笑) showの引数を設定するのは、難しかったですが勉強になりました。
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?