Lab 6 - XML and Trees
- Open your homework 5 in IntelliJ (or other IDE, so that it can
be changed), be sure that unit testing works.
- If you do not have the latest version of your work on
bitbucket (or github), create a commit and push it. If
necessary, refer to the materials of the first lab. The test
file NodeTest.java must also be included in the
version control.
- The teacher will assign you a partner for this lab.
- Show that all the tests pass on your computer (if necessary,
check the materials of the first lab), that the work has been
submitted by the deadline and the teachers comments (must
contain "ok"). The partner does the same.
- Divide the roles: developer and tester. One partner
("developer") is responsible for the file Node.java,
the other partner ("tester") is responsible for the file NodeTest.java.
- Development: Add a new method toXML to
convert a given tree into a pseudo-XML form (similar to the leftParentheticRepresentation
method), which applies to the tree's root vertex this and
outputs a string describing the tree's structure with the
opening tags <L1>, <L2> ... (the number indicates
the depth of the vertex), the vertex names and with the
corresponding closing tags </L1>, </L2>, ...
as shown in the following example. If the right parenthetic
representation is:
"((C)B,(E,F)D,G)A"
then the result must be:
<L1> A
<L2> B
<L3>
C </L3>
</L2>
<L2> D
<L3>
E </L3>
<L3>
F </L3>
</L2>
<L2> G </L2>
</L1>
Implement the method toXML and include 3 - 4 examples
to the main method. Print both the left parenthetic
representation and the pseudo-XML of the example trees.
- Testing: Write about 5 test cases for toXML
that cover all the examples and add them to existing tests (use
the junit4
framework, see the test file NodeTest.java for an
example).
- Share your result with the partner and test the new solution
in both computers.
- Make a new commit "Developer: name,
Tester: name" and upload it to
bitbucket (or github), the partner will do the same with their
code. Do this after the testing part is finished.
- Show the commit, the tests and running examples to the
teacher. You can also run tests from the command line if there
is a problem with the IDE.
- The teacher will discuss and ask questions about your work.
- The teacher inputs grades to SIS.
Jaanus Pöial