Question: In C++ using classes, take the code below making a class -- called Asteroid. and add the objects. It will have a size and speed.

In C++ using classes, take the code below making a class -- called Asteroid. and add the objects.

It will have a size and speed.

Create 2 variables of type asteroid and set the size and speed.

The setsize function should check if the size is below 1 or above 20. If it is below 1, make it 1. If it is above 20, make it 20. Otherwise, keep the size that was sent in. #include using namespace std; class Asteroid { private: int size , speed; public: Asteroid() { } void setSize(int s){ if(s < 1){ size = 1; } else if(size > 20){ size = 20; } else{ size = s; } } }; int main() { }

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!