Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago