LoginSignup
0
0

More than 3 years have passed since last update.

ruby でプログラミング(途中)

Last updated at Posted at 2020-07-05

アウトプットです

前回学んだことを生かしてrubyを使ってプログラミングを組んでます。

まだ途中ですが今回はMUPで学んだ店舗の利益計算を組んでみたいと思います。
本当はささっと仕上げる予定が構想をねるほど長くなりそうに。。。

とりあえず下記が途中です

def input_data(total_datas)
  puts "店名を入力してください"
    store_name = gets.chomp
  puts "平日ランチの客数"
    weekday_lunch_guest = gets.to_i
  puts "平日ディナーの客数"
    weekday_dinner_guest = gets.to_i
  puts "休日ランチの客数"
    weekend_lunch_guest = gets.to_i
  puts "休日ディナーの客数"
    weekday_dinner_guest = gets.to_i
  puts "平日ランチの客単価"
    weekday_lunch_guest_price = gets.to_i
  puts "平日ディナーの客単価"
    weekday_dinner_guest_price = gets.to_i
  puts "休日ランチの客単価"
    weekend_lunch_guest_price = gets.to_i
  puts "休日ディナーの客単価"
    weekend_dinner_guest_price = gets.to_i
  puts "平日の営業日"
    weekday_business = gets.to_i
  puts "休日の営業日"
    weekend_business = gets.to_i
  puts "ランチの原価"
    lunch_cost = gets.to_i
  puts "ディナーの原価"
    dinner_cost = gets.to_i
  puts "家賃を入力してください"
    rent = gets.to_i
  puts "光熱費を入力してください"
    utility_cost = gets.to_i
  puts "人件費を入力してください"
    saraly = gets.to_i
  puts "月間仕入れを入力してください"
    stocking = gets.to_i

  total_data = {store_name: store_name, weekday_lunch_guest: weekday_lunch_guest, weekday_dinner_guest: weekday_dinner_guest, weekend_lunch_guest: weekend_lunch_guest, weekday_dinner_guest: weekday_dinner_guest, weekday_lunch_guest_price: weekday_lunch_guest_price,  weekday_dinner_guest_price:  weekday_dinner_guest_price, weekend_lunch_guest_price: weekend_lunch_guest_price, weekend_dinner_guest_price: weekend_dinner_guest_price, weekday_business: weekday_business, weekend_business: weekend_business, lunch_cost: lunch_cost, dinner_cost: dinner_cost, rent: rent, utility_cost: utility_cost, saraly: saraly, stocking: stocking}

  total_datas << total_data
end

def show_store(total_datas)
  total_datas.each_with_index do |total_data, i|
    puts "[#{i}]: #{total_data[:store_name]}"
  end

  puts "確認したい番号を入力して下さい。"
  input = gets.to_i
  total_data = total_datas[input]

  if total_data
    show_data(total_data)
  else
    puts "該当する番号はありません。"
  end
end

def show_data(total_data)
end




def end_program
  exit
end

def exception
  puts "入力された値は無効な値です"
end

total_datas = []

while true do
  puts "番号を入力してください"
  puts "[0]店を登録する"
  puts "[1]データを参照する"
  puts "[2]アプリを終了する"
    input = gets.to_i

  if input == 0 then
    input_data
  elsif input == 1 then
    show_store(total_datas)
  elsif input == 2 then
    end_program
  else
    exception
  end
end

show_data(total_data)で
ハッシュ内の値の数値を順次計算して最終的には利益予測をたてるみたいなのを組みたいなと考えています。
まぁExcelの方が手っ取り早いんですが笑

0
0
1

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