Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri…..

CATALOG CD CD CD TITLE TITLE TITLE ARTIST ARTIST COUNTRY ARTIST COUNTRY COUNTRY COMPANY COMPANY COMPANY PRICE PRICE PRICE YEAR YEAR YEARProblem Description:

The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retrieve values. The data to be converted into tree form is a text file containing hierarchically-structured information. Here is an example, formatted to show the hierarchy:

Empire Burlesque

Bob Dylan

USA

Columbia

10.90

1985

Hide your heart

Bonnie Tyler

UK

CBS Records

9.90

1988

Greatest Hits

Dolly Parton

USA

RCA

9.90

1982

The CATALOG contains multiple CDs and each CD contains 6 values, TITLE, ARTIST, COUNTRY, COMPANY, PRICE and YEAR. Each entity (CATALOG, CD, TITLE etc.) is formed by enclosing a value or other entity between two tags, each formed by placing the angle-brackets (< and >) around the name of the entity. The leading tag contains the name and the ending tag contains the name, preceded by a forward-slash ( / ). Thus the TITLE entity is a text string that looks like this:

 

Hide your heart

The resulting tree will contain nodes containing the entities. A tree containing the information in the sample above could resemble the following diagram:

The directed lines connecting the diagram elements represent reference-variable values or “pointers”. The lowest-level nodes (TITLE, ARTIST etc.) will contain class-level String variables containing the values (“Empire Burlesque”, and “Bob Dylan” etc.) The rest of the tree exists merely to record the structure of the data.

There are two files associated with this exercise, one contains a more extensive catalog of CDs and the other contains a list of domestic garden plants. You can demonstrate your program on either of these files.

Your program should have a class, containing the main method and a separate class, named “XML_Data” which contains the tree-building and the tree-searching methods. A 3rd class will define the nodes. As usual in these cases, the tree will exist in RAM only, not in the code. The code will have the reference to the root node and the remainder of the structure will exist in RAM only.

When the program starts, the main will instantiate the XML_Data class and it will immediately read the indicated text file and build the tree. When that task has been completed, main will communicate with the user to perform searches and retrievals of information.

Each “leaf-node” (lowest-level node containing a value) has an associated path. For example, in the plant catalog file, the path “CATALOG.PLANT[3].PRICE will find the element $9.90 . The “subscript” [3] is needed because merely specifying “PLANT” in the path would not allow the user to distinguish between the 36 sub-elements of CATALOG.

There should be a method to search the data file and return the number of sub-elements at the location described by the path. For example, the path “CATALOG” will return the number 36 because there are 36 sub-elements named PLANT at that point. The path “CATALOG.PLANT[12]” will return the number 6 because there are 6 sub-elements of PLANT at that point. The path “CATALOG.PLANT[2].COMMON” will return the number 0 because COMMON at that location has no sub-elements.

There should be a second method to search the data file, find the designated element and return a String containing it and its sub-elements. For example, the path “CATALOG.PLANT[3]” will return a String containing the following:

Cowslip

Caltha palustris

4

Mostly Shady

$9.90

030699

The path “CATALOG.PLANT[3].ZONE” will return a String containing the following:

4

Your requests should be case-insensitive.

The diagram is above.

I need the ful complete answer.

Expert Answer

 

Program code screen shot:

Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri..... 1

Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri..... 2

Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri..... 3

Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri..... 4

Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri..... 5

Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri..... 6

Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri..... 7

Sample output:

Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri..... 8

Question & Answer: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retri..... 9

Program code to copy in below tab:

Still stressed from student homework?
Get quality assistance from academic writers!