Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

ISBN: 0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

l List elements to consider when developing an employee handbook.

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago