Question: A possible CodeRunner question of the type Write a class could be the following. Write a class with name Bear which meets the following requirements:

A possible CodeRunner question of the type "Write a class" could be the following.
Write a class with name Bear which meets the following requirements:
There is a constructor which takes three parameters of type Integer: age, weight, and sleepTime.
There is a method getWeight() which returns the weight of the animal.
There is a method addSleepTime(additionalTime) which increases the sleepTime by additionalTime.
There is a method eat() which returns the following String:
I eat
Your code is automatically checked with several test cases. One of them is listed here with the expected result.
For example:
Test Result
youngbear = Bear(2,15,180)
print("Young bear is "+ str(youngbear.age)+" years old. His weight is "+ str(youngbear.weight)+" and his sleep time is "+ str(youngbear.sleepTime))
youngbear.addSleepTime(10)
print("A few month ago, his sleep time was "+ str(youngbear.sleepTime))
Young bear is 2 years old. His weight is 15 and his sleep time is 180
A few month ago, his sleep time was 190
Answer:(penalty regime: 0%)

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!