Question: Create a class called Matreshka (Russian doll). The fields should include: a name (String) and a height (int). In addition, there should be a field

 Create a class called Matreshka (Russian doll). The fields should include:

Create a class called Matreshka (Russian doll). The fields should include: a name (String) and a height (int). In addition, there should be a field to hold Matreshkas daughter of type Matreshka. A constructor for the class can take a name and a height. Matreshkas name can be a combination of the name and height. For example, if Matreshkas name passed to the constructor is Natasha, and the height is 9, the name can be Natasha9. In the constructor matreshkas daughter will be created as long as mothers height is greater than daughters by, say, 1 inch. The smallest matreshka should be 1 inch tall and its daughter should be null. In your driver class create a matreshka family. You can make the tallest mama matreshka height be, say, 9 inches and the family name, say, Natasha, Olga or Tatiana. Create an ArrayList or LinkedList of Matreshkas and populate it with matreshkas in descending height order. Using a recursive method print matreshkas names in decreasing height order. Using another recursive method print the names in increasing height order.

Programming Challenge 5, Russian Dolls-50 points Create a class called Matreshka (Russian doll). The fields should include: a name (String) and a height (int). In addition, there should be a field to hold Matreshka's daughter of type Matreshka. A constructor for the class can take a name and a height. Matreshka's name can be a combination of the name and height. For example, if Matreshka's name passed to the constructor is Natasha, and the height is 9, the name can be Natasha9. In the constructor matreshka's daughter will be created as long as mothers height is greater than daughters by, say, 1 inch. The smallest matreshka should be 1 inch tall and its daughter should be null In your driver class create a matreshka family. You can make the tallest "mama" matreshka height be, say, 9 inches and the family name, say, Natasha, Olga or Tatiana. Create an ArrayList or LinkedList of Matreshkas and populate it with matreshkas in descending height order. Using a recursive method print matreshkas names in decreasing height order. Using another recursive method print the names in increasing height order

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!