Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this programming assignment, you are going to create a class named Animal tha

ID: 3603325 • Letter: I

Question

In this programming assignment, you are going to create a class named Animal that is used to store information about an animal. You will then create a program that takes user input, allowing the user to create multiple Animal objects. Finally, you will retrieve the information stored in those objects and display it.

Please Use Python 3 and include copy of the code. Thanks!

In this programming assignment, you are going to create a class named Animal that is used to store information about an animal. You will then create a program that takes user input, allowing the user to create multiple Animal objects. Finally, you will retrieve the information stored in those objects and display it. Animal Class attributes and methods. Save this Write a class named Animal that has the following clas s as Animal.py Attributes _ a n i mal-t y pe: a hidden attribute used to indicate the animal's type. For example: gecko, walrus, tiger, etc. _name: a hidden attribute used to indicate the animal's name. _mood: a hidden attribute used to indicate the animal's mood. For example: happy, hungry, or sleepy Methods init__:this method should create the three attributes above and assign their default values. The value ofmood should be set randomly. Generate a random number between 1 and 3. Then: If the number is 1, the-mood field should be set to a value of “happy" If the number is 2, the_mood field should be set to a value of "hungry" If the number is 3, the-mood field should be set to a value of “sleepy" get animal_type: this method should return the value of the animal_type field. get_name: this method should return the value of the__name field. check_mood: this method should return the value of the__mood field.

Explanation / Answer

1 // Figure 10.1: PolymorphismTest.java 2 // Assigning superclass and subclass references to superclass and 3 // subclass variables. 4 5 public class PolymorphismTest 6 { 7 public static void main( String args[] ) 8 { 9 // assign superclass reference to superclass variable 10 CommissionEmployee3 commissionEmployee = new CommissionEmployee3( 11 "Sue", "Jones", "222-22-2222", 10000, .06 ); 12 13 // assign subclass reference to subclass variable 14 BasePlusCommissionEmployee4 basePlusCommissionEmployee = 15 new BasePlusCommissionEmployee4( 16 "Bob", "Lewis", "333-33-3333", 5000, .04, 300 ); 17 18 // invoke toString on superclass object using superclass variable 19 System.out.printf( "%s %s: %s ", 20 "Call CommissionEmployee3's toString with superclass reference ", 21 "to superclass object", commissionEmployee.toString() ); 22 23 // invoke toString on subclass object using subclass variable 24 System.out.printf( "%s %s: %s ", 25 "Call BasePlusCommissionEmployee4's toString with subclass", 26 "reference to subclass object", 27 basePlusCommissionEmployee.toString() ); 28 29 // invoke toString on subclass object using superclass variable 30 CommissionEmployee3 commissionEmployee2 = 31 basePlusCommissionEmployee; 32 System.out.printf( "%s %s: %s ", 33 "Call BasePlusCommissionEmployee4's toString with superclass", 34 "reference to subclass object", commissionEmployee2.toString() ); 35 } // end main 36 } // end class PolymorphismTest

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote