Hi !
I need help please, I want to write java code, but that is difficult for me. it is about using annotation, reflection and XLM_ file.
Please help me!
I want explaintion with code and I want to se result please!
My assignment is!
Using the annotations and reflection API write an XML file exporter for composite objects of any kind. That is, the exporter should rely only on the annotations in the class definitions of the composite objects to produce the exported XML. The XML tags are defined within the annotations, and otherwise the exporter is totally indifferent of the type of the exported object, as long as the required annotations are provided. In particular, there should be no explicit types (for example, Tree) mentioned in the code.
For example, for the following annotated class:
@Element(name="node")public class Tree<T> {
private Tree<T>[] children = null;private T value;
public Tree(T v, Tree<T>[] trees) { children = trees; value = v; }public Tree(T v) { value = v; }
1
@SubElements(name="subnodes")
public Tree<T>[] getChildren() { return children; }
@ElementField(name="value")
public T getValue() { return value; } }
the following program (you have to implement the annotation classes and the Saver class with method save(Object o)):
Tree<String> t =
new Tree<String>("top",
new Tree[] {
new Tree("sub1"),new Tree("sub2")
});
Saver s = new Saver(); String r = s.save(t);
System.out.println(r);
should produce this output:
<node value="top"> <subnodes>
<node value="sub1"/>
<node value="sub2"/> </subnodes>
</node>
Thanks!
Hi ! I need help please, I want to write java code, but that is difficult...
The following code has a problem with polymorphism. I keep getting a runtime error. Error: "An unhandled exception of type System.InvalidCastException occured in polymorphism.exe" Apparently, I need one line of code to fix it. C# Code: class Sensor { private string sensorName; public Sensor(string _name) { sensorName = _name; } public virtual void ActionType() { Console.WriteLine("Sensor Detect Nothing."); } } class SmokeSensor : Sensor { private string type;...
I have almost done with this code to Implement Huffman Coding. However I have an error at the "Heap<Tree>". Could anyone help with solving this issue, really appreciated. Thank you!! import java.util.Scanner; public class HuffmanEncoding { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a text: "); String text = input.nextLine(); int[] counts = getCharacterFrequency(text); // Count frequency System.out.printf("%-15s%-15s%-15s%-15s\n", "ASCII Code", "Character", "Frequency", "Code"); Tree tree = getHuffmanTree(counts); // Create a Huffman tree String[]...
For this assignment, you will write a program to work with Huffman encoding. Huffman code is an optimal prefix code, which means no code is the prefix of another code. Most of the code is included. You will need to extend the code to complete three additional methods. In particular, code to actually build the Huffman tree is provided. It uses a data file containing the frequency of occurrence of characters. You will write the following three methods in the...
In need of JAVA CODE FOR THIS OBJECTIVE: Modify the BST class I gave you as follows: In the case in which the deleted node has two children, write the code in two ways. a) always replace the deleted node with the largest node on the left. b) count how many deletions have been done, and for even deletions replace the deleted node with the largest node on the left, for odd deletions, replace the deleted node with the smallest...
hi, I am suppose to implement that method in java for bst but the result doesn't work as excpected * _Part 8: Implement this method._ * * toString() is a method defined by Java's Object class * that can be used to provide a String representation for your * class. It is called anytime you concatenate an Object to * a String. * * Build a string representation of the BST that describes both * the values stored inside and...
This is my code for family tree, but i am confused on how to make a main class that will use these methods. public class FamilyTree { private class Node { String name; Node next; Node child; public Node(String name) { this.name = name; next = null; child = null; } } public Node addSibling(Node node, String name) { if(node == null) return null; while(node.next != null) node = node.next; return(node.next = new Node(name)); } public Node addChild(Node...
Return a method as an expression tree
Hi guys.
I need to return a method as an expression tree, it's currently
returning null.
public static ExpressionTree getExpressionTree(String
expression)
throws Exception {
char[] charArray = expression.toCharArray();
Node root = et.constructTree(charArray);
System.out.println("infix expression is");
et.inorder(root);
return et;
}
In the above method, et needs to have a value.
-- Take a look at the complete class below.
Kindly assist.
; public class ExpressionTree extends BinaryTree { private static final String DELIMITERS...
******Java Programming Hi guys, I really need you help. I created a code for my java course, but it keep giving me error messages. Majority of my code is fine but some keep display error on my console. I was hoping someone could pin points the problem. .There are three classes with the testCenter class being the main class. In the following is the assignment, and the bottom is my code. Please help! Assignment: Concepts: GUI User Design Graphics Deployment...
Does not pass the testcase
testDTreeAdvancedReRootchangesParent
Java
I'm trying to extend the implementation of a general tree with
new operations that change the structure of the tree.
I've created 5 classes: Node.java, SimpleNode.java, Tree.java,
RerootableTree.java and SimpleTree.java(which is the main java
class that I need to change).
The code does not pass ONE TESTCASE :
testDTreeAdvancedReRootchangesParent
The code passes all the other testcases except theone mentioned
above. This is because in the SimpleTree.java the method
"reRoot(Node newRoot)" is most likely...
Need help in the below question. Answer in java Start with the tree.java program (Listing 8.1) and modify it to create a binary tree from a string of letters (like A, B, and so on) entered by the user. Each letter will be displayed in its own node. Construct the tree so that all the nodes that contain letters are leaves. Parent nodes can contain some non-letter symbol like +. Make sure that every parent node has exactly two children....