You need to make an AngryBear class.(In java) The AngryBear class must have 2 instance variables. The...

60.1K

Verified Solution

Question

Programming

You need to make an AngryBear class.(In java)

The AngryBear class must have 2 instance variables.

The first instance variable will store the days the bear hasbeen awake.

The second instance variable will store the number of teeth forthe bear.

The AngryBear class will have 1 constructor that takes in valuesfor days awake and number of teeth.

The AngryBear class will have one method isAngry();

An AngryBear is angry if it has been awake for more than 3 daysand has less than 10 teeth or has no teeth or has been awake formore than 5 days.

Otherwise, the AngryBear is not really angry but he could bequite annoyed.

to test this code use

public void run() {

AngryBear a = new AngryBear( 10, 3 );

System.out.println( a.isAngry() ); //prints true

AngryBear b = new AngryBear( 10, 35 );

System.out.println( b.isAngry() );

AngryBear c = new AngryBear( 1, 25 );

System.out.println( c.isAngry() );

AngryBear d = new AngryBear( 6, 40 );

System.out.println( d.isAngry() );

AngryBear e = new AngryBear( 1, 1 );

System.out.println( e.isAngry() );

AngryBear f = new AngryBear( 111, 111 );

System.out.println( f.isAngry() );

}

Answer & Explanation Solved by verified expert
3.7 Ratings (542 Votes)
Codeclass is named as Angry Bearfile should be named as AngryBearjavaclass AngryBear instance variables int days int teeth constructor AngryBearint daysint teeth thisdaysdays thisteethteeth method boolean isAngry ifdays3 teeth5 returntrue else returnfalse run method void run AngryBear a new AngryBear 10    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students