please provide steps on how to get screenshot of Junit tests results
IntTree.java :
public interface IntTree {
public void buildTree(int max);
public String getPreOrder();
public String getInOrder();
public String getPostOrder();
public void printSidewaysIndented();
}
IntTreeNode.java :
class IntTreeNode {
public int data;
public IntTreeNode left;
public IntTreeNode right;
public IntTreeNode (int data, IntTreeNode left, IntTreeNode right) {
this.data = data;
this.left = left;
this.right = right;
}
}
BinaryIntTree.java :
class BinaryIntTree {
private IntTreeNode overallRoot;
// pre: overallRoot has nothing important in it because the old values will be lost
// post: overallRoot points to the root of a tree that contains max nodes
public void buildTree(int max) {
overallRoot = buildTree(1, max);
}
// pre: n is the value to be assigned to the new node
// post: a new subtree has been created with data value n
private IntTreeNode buildTree(int n, int max) {
if (n > max) {
return null;
} else {
IntTreeNode left = buildTree(2*n, max);
IntTreeNode right = buildTree(2*n +1, max);
return new IntTreeNode(n, left, right);
}
}
// pre: none
// post: returns the data values of the tree using a preorder traversal
public String getPreOrder() {
// todo
return "";
}
// pre: none
// post: returns the data values of the tree using a inorder traversal
public String getInOrder() {
String result = "";
result = getInOrder(overallRoot, result);
return result.strip();
}
// pre: none
// post: the values of the sub tree are added to the result string in inorder traverseral order
private String getInOrder(IntTreeNode root, String result) {
if (null != root) {
result = getInOrder(root.left, result);
result = result + root.data + " ";
result = getInOrder(root.right, result);
}
return result;
}
// pre: none
// post: returns the data values of the tree using a postorder traversal
public String getPostOrder() {
// todo
return "";
}
// pre: none
// post: the tree is print to console rotated 90 degree so the root is on the far left
public void printSidewaysIndented() {
printSidewaysIndented(overallRoot, 0);
}
// pre: none
// post: the subtree is printed spaced out to appropriately for the level specified
private void printSidewaysIndented(IntTreeNode root, int level) {
if (null != root) {
printSidewaysIndented(root.right, level + 1);
for (int i = 0; i < level; i ++) {
System.out.print(" ");
}
System.out.println(root.data);
printSidewaysIndented(root.left, level + 1);
}
}
}
BinaryIntTreeTest.java :
import static org.junit.Assert.assertEquals;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class BinaryIntTreeTest {
// buildTree(5) looks like this sideways:
// 3
//
// 1
// 5
// 2
// 4
@Test
public void testBuildTree() {
BinaryIntTree tester = new BinaryIntTree();
// add 1 elements to tree
tester.buildTree(1);
assertEquals("after adding nodes to tree the inorder print should be", "1", tester.getInOrder());
// add 5 elements to tree
tester.bu.
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
please provide steps on how to get screenshot of Junit tests results I.pdf
1. please provide steps on how to get screenshot of Junit tests results
IntTree.java :
public interface IntTree {
public void buildTree(int max);
public String getPreOrder();
public String getInOrder();
public String getPostOrder();
public void printSidewaysIndented();
}
IntTreeNode.java :
class IntTreeNode {
public int data;
public IntTreeNode left;
public IntTreeNode right;
public IntTreeNode (int data, IntTreeNode left, IntTreeNode right) {
this.data = data;
this.left = left;
this.right = right;
}
}
BinaryIntTree.java :
class BinaryIntTree {
private IntTreeNode overallRoot;
// pre: overallRoot has nothing important in it because the old values will be lost
// post: overallRoot points to the root of a tree that contains max nodes
public void buildTree(int max) {
overallRoot = buildTree(1, max);
}
// pre: n is the value to be assigned to the new node
// post: a new subtree has been created with data value n
private IntTreeNode buildTree(int n, int max) {
if (n > max) {
return null;
} else {
IntTreeNode left = buildTree(2*n, max);
2. IntTreeNode right = buildTree(2*n +1, max);
return new IntTreeNode(n, left, right);
}
}
// pre: none
// post: returns the data values of the tree using a preorder traversal
public String getPreOrder() {
// todo
return "";
}
// pre: none
// post: returns the data values of the tree using a inorder traversal
public String getInOrder() {
String result = "";
result = getInOrder(overallRoot, result);
return result.strip();
}
// pre: none
// post: the values of the sub tree are added to the result string in inorder traverseral order
private String getInOrder(IntTreeNode root, String result) {
if (null != root) {
result = getInOrder(root.left, result);
result = result + root.data + " ";
result = getInOrder(root.right, result);
}
return result;
}
// pre: none
// post: returns the data values of the tree using a postorder traversal
public String getPostOrder() {
// todo
return "";
}
// pre: none
// post: the tree is print to console rotated 90 degree so the root is on the far left
public void printSidewaysIndented() {
printSidewaysIndented(overallRoot, 0);
}
// pre: none
// post: the subtree is printed spaced out to appropriately for the level specified
3. private void printSidewaysIndented(IntTreeNode root, int level) {
if (null != root) {
printSidewaysIndented(root.right, level + 1);
for (int i = 0; i < level; i ++) {
System.out.print(" ");
}
System.out.println(root.data);
printSidewaysIndented(root.left, level + 1);
}
}
}
BinaryIntTreeTest.java :
import static org.junit.Assert.assertEquals;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class BinaryIntTreeTest {
// buildTree(5) looks like this sideways:
// 3
//
// 1
// 5
// 2
// 4
@Test
public void testBuildTree() {
BinaryIntTree tester = new BinaryIntTree();
// add 1 elements to tree
tester.buildTree(1);
assertEquals("after adding nodes to tree the inorder print should be", "1", tester.getInOrder());
// add 5 elements to tree
tester.buildTree(5);
assertEquals("after adding nodes to tree the inorder print should be", "4 2 5 1 3",
tester.getInOrder());
tester.printSidewaysIndented();
}
4. @Test
public void testGetPreOrder() {
BinaryIntTree tester = new BinaryIntTree();
// add 5 elements to tree
tester.buildTree(5);
assertEquals("after adding nodes to tree the inorder print should be", "1 2 4 5 3",
tester.getPreOrder());
}
@Test
public void testGetInOrder() {
BinaryIntTree tester = new BinaryIntTree();
// add 5 elements to tree
tester.buildTree(5);
assertEquals("after adding nodes to tree the inorder print should be", "4 2 5 1 3",
tester.getInOrder());
}
@Test
public void testGetPostOrder() {
BinaryIntTree tester = new BinaryIntTree();
// add 5 elements to tree
tester.buildTree(5);
assertEquals("after adding nodes to tree the inorder print should be", "4 5 2 3 1",
tester.getPostOrder());
}
}
Binary Tree Long Homework Assignment Overview: this week you are to implement parts of a
Binary Tree class. You will be given an interface, a partially complete BinarylntTree.java class,
an IntTreeNode.java class, and a BinarylntTreeTest .java unit test file. Your assignment is to
complete the BinarylntTree.java class so that it passes all the unit tests. To Do: 1. Download the
following files: - IntTree.java - BinarylntTree.java - BinarylntTreeTest.java 2. You are to
complete the BinarylntTree.java class file so that it will implement all the methods in the IntTree
interface and passes all unit tests in BinarylntTreeTest. 3. When done you are to submit via
canvas your BinaryIntTree.java file and a screenshot image showing the pass/fail results of
running the unit tests.