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: 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 orderStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started