Question: 5. Consider the following Ruby class: class MyCar def initialize(year, model, color) @year year @model-model @color- color @current-speed 0 end def brake (number) @current-speed-= number

 5. Consider the following Ruby class: class MyCar def initialize(year, model,

5. Consider the following Ruby class: class MyCar def initialize(year, model, color) @year year @model-model @color- color @current-speed 0 end def brake (number) @current-speed-= number puts "You push the brake and decelerate #(number) mph." end def current_speed puts "You are now going #t@current-speedy mph..' end def shut dowrn @current-speed 0 puts "Let's park this bad boy!" end end List the instance variables belonging to the class MyCar. (2 points) Write a Ruby statement to create an instance of the class MyCar having the following initial values: year = 2017, model = Chevrolet Colorado, color = black (3 points) Write a Ruby statement to create a method called speed_up. The method should a) increase the speed of a car by the quantity of the given input parameter, and b) output a message indicating the updated speed of the car. (7 points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!