Question: Goal: Learn to define classes with internal state, and getter and setter methods. Question Goal: Learn to define classes with internal state, and getter and
Goal: Learn to define classes with internal state, and getter and setter methods. Question
Goal: Learn to define classes with internal state, and getter and setter methods.
Assignment: Write the definition of a class named Asteroid that has the following methods:
An init method that initializes the following attributes:
An attribute width that should be assigned ;
An attribute height that should be assigned ;
An attribute depth that should be assigned ;
An attribute speed that should be assigned
A method setsize that accepts three arguments and assigns the first to width, the second to height, and the third to depth;
A method setspeed that accepts one argument and assigns it to speed;
A method getsize that returns a tuple of three items, the first being width, the second height, and the third depth;
A method getspeed that returns the value of speed.
Assignment: Write the definition of a class named Asteroid that has the following methods:
An init method that initializes the following attributes:
An attribute width that should be assigned ;
An attribute height that should be assigned ;
An attribute depth that should be assigned ;
An attribute speed that should be assigned
A method setsize that accepts three arguments and assigns the first to width, the second to height, and the third to depth;
A method setspeed that accepts one argument and assigns it to speed;
A method getsize that returns a tuple of three items, the first being width, the second height, and the third depth;
A method getspeed that returns the value of speed
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
