Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions kadai1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
year = gets.to_i #gets(標準入力)

# 以下の条件分岐に、新しい条件を追加してください
if
puts "#年にオリンピックはまだありません"
elsif

elsif
puts "#年は夏季オリンピックが開催されました"
if year < 1896 || year > 2020
puts "#{year} 年にオリンピックはまだありません"
elsif year == 1916 || year == 1940 || year == 1944
puts "#{year} 年にオリンピックは開催されされませんでした"
elsif year % 4 == 0
puts "#{year} 年は夏季オリンピックが開催されました"
else
puts "#年は夏季オリンピックイヤーではありません"
puts "#{year} 年は夏季オリンピックイヤーではありません"
end
9 changes: 7 additions & 2 deletions kadai2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
{year: 1920, city: "アントワープ"},
{year: 1924, city: "パリ", note: "同じ都市での2回目の開催は初"},
{year: 1928, city: "アムステルダム"},
{year: 1932, city: "ロサンゼルス"}
{year: 1932, city: "ロサンゼルス"},
{year: 2020, city: "東京", note: "コロナウイルスで2021年に延期"}
]

puts "第1~10回大会のオリンピック一覧"

# each文を用いて、オリンピックの情報を出力してください


olympics.each do |event|
puts "ーーーーーーーーーーーーーーーーー"
puts "#{event[:year]}年#{event[:city]}大会\n"
puts "豆知識:#{event[:note]}" if event.key? :note
end

# 豆知識がある場合のみ豆知識について出力してください
12 changes: 7 additions & 5 deletions kadai3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ class Menu
attr_accessor :price

# get_total_priceメソッドを定義してください



return "#{self.name} #{total_price}vnd"

def get_total_price count
total_price = count * price
total_price -= 10000 unless count < 3
"#{name} #{total_price} VND."
end
end

menu1 = Menu.new
menu1.name = "Phở"
menu1.price = 30000

puts menu1.get_total_price 5

# menu1に対してget_total_priceメソッドを呼び出してください
15 changes: 10 additions & 5 deletions kadai4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Menu
attr_accessor :name
attr_accessor :price

def initialize(name:, price:)
def initialize name:, price:
self.name = name
self.price = price
end
Expand All @@ -13,11 +13,16 @@ def info
end

#メニューの変数を定義してください
menu1 =
menu2 =
menu3 =

menu1 = Menu.new name: "Pho Bo", price: 40000
menu2 = Menu.new name: "Pho Ga", price: 350000
menu3 = Menu.new name: "Pho Hai San", price: 50000

# 変数menusを定義して配列を代入してください
menus = [menu1, menu2, menu3]

# menusに対して繰り返し処理を実行してください
menus.each do |menu|
puts menu.info
end

# menusに対して繰り返し処理を実行してください
40 changes: 30 additions & 10 deletions kadai5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ class Menu
attr_accessor :name
attr_accessor :price

def initialize(name:, price:)

def initialize name:, price:
self.name = name
self.price = price
end

def info
return "#{self.name} #{self.price}vnd"
"#{name} #{price}VND"
end
end

Expand All @@ -17,22 +18,41 @@ class Drink < Menu

# initializeメソッドをオーバーライドする
# nameとpriceはsuperとする

def initialize name:, price:, size:
super name: name, price: price
self.size = size
end

def info
return "#{self.name} #{self.price}vnd (#{self.size}サイズ)"
"#{name} #{price}VND (#{size}サイズ)"
end
end

menu1 = Menu.new(name: "Phở", price: 30000)
menu2 = Menu.new(name: "Bún chả", price: 40000)
menu3 = Menu.new(name: "bánh mì", price: 20000)
menu1 = Menu.new name: "Phở", price: 30000
menu2 = Menu.new name: "Bún chả", price: 40000
menu3 = Menu.new name: "bánh mì", price: 20000
menu4 = Drink.new name: "Milo", price: 5000, size: "M"
menu5 = Drink.new name: "Nestea", price: 10000, size: "S"

# Drinkの変数を定義してください

menus = [menu1, menu2, menu3, menu4, menu5]

# 変数menusを定義して配列を代入してください
menus.each_with_index do |menu, index|
puts "#{index + 1}. #{menu.info}"
end

puts "Choose your menu: "

order = gets.to_i()

if menus[order - 1] == nil
return puts "Unavailable"
end

selected_menu = menus[order - 1]

puts "選択されたメニュー: #{selected_menu.name}"
puts "お会計は #{selected_menu.price}VND"

menus.each do |menu|
puts "#{menu.info}"
end
1 change: 1 addition & 0 deletions practice.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello World"
2 changes: 1 addition & 1 deletion practice.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
これはプルリクエスト練習用のリポジトリです。
スライドの内容を進めてプルリクエストまで実施してみましょう。
スライドの内容を進めてプルリクエストまで実施してみましょう。
21 changes: 21 additions & 0 deletions sample-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore Byebug command history file.
.byebug_history
48 changes: 48 additions & 0 deletions sample-app/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Loading