Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

平日課題2:Rubyに関する課題 #1

Open
busitora opened this issue Mar 4, 2019 · 0 comments
Open

平日課題2:Rubyに関する課題 #1

busitora opened this issue Mar 4, 2019 · 0 comments

Comments

@busitora
Copy link
Owner

busitora commented Mar 4, 2019

課題詳細

・アプリ名(ディレクトリ名)はcamp_weekday_task2です。
camp_weekday_task2の直下に配置しているcar.rbまたはanimal.rbを使用し、実装して下さい。
・以下の設問順に実装して下さい。

課題リンク

平日課題2: Rubyに関する課題

受け入れ基準

  • exercise02-1.rbが期待通りの出力をすること。
  • exercise02-2.rbが期待通りの出力をすること。
  • exercise02-3.rbが期待通りの出力をすること。
  • exercise02-4.rbが期待通りの出力をすること。
  • exercise02-5.rbが期待通りの出力をすること。

Carクラスのspeed_upメソッドの修正(課題2-1)

@speedが30以上になった時にアラートを表示。
@speedが50以上になった時にアラートを表示した後、speed_downメソッドを実行。

Carクラスを継承したTrackCarクラスの作成(課題2-2)

attr_reader :load_weightを追加。
・引数がnumber、color、load_weightであるinitializeメソッドを追加。load_weightはデフォルトで500を設定。

Carクラスでget_onメソッドの追加(課題2-3)

attr_accessor :passengersを追加。
・定数MAX_PASSENGERSを追加。
・initializeメソッドに@passengersの初期値を追加。
get_onメソッドの定義。

Carクラスにクラスメソッドcount_infoを追加(課題2-4)

Animalクラスを継承したDogクラス、Catクラスを作成(課題2-5)

・Dogクラス、Catクラスでそれぞれ@voiceに文字列を代入し、各インスタンスで違った鳴き声を出力。

close #1

@busitora busitora changed the title Rubyに関する課題 平日課題2:Rubyに関する課題 Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant