quiz حل الأسئلة الجامعية manage_search الأرشيف

تم الحل ✓
categoryبرمجة وتطوير البرمجيات schoolبكالوريوس event_available2026-07-13

السؤال

Transcribed Image Text:

3. Car Class Write a class named Car that has the following member variables: ⚫ yearModel-an int that holds the car's year model • make-a string that holds the make of the car speed-an int that holds the car's current speed In addition, the class should have the following constructor and other member functions: • Constructor-The constructor should accept the car's year model and make as argu ments. These values should be assigned to the object's year Model and make member variables. The constructor should also assign 0 to the speed member variables. ⚫ Accessor-appropriate accessor functions to get the values stored in an object's yearModel, make, and speed member variables • accelerate-The accelerate function should add 5 to the speed member vari- able each time it is called. • brake-The brake function should subtract 5 from the speed member variable each time it is called. Demonstrate the class in a program that creates a Car object, then calls the accelerate function five times. After each call to the accelerate function, get the current speed of the car and display it. Then, call the brake function five times. After each call to the brake function, get the current speed of the car and display it.

check_circle الجواب — حل مفصل خطوة بخطوة

hourglass_top