Page 1 of 1

Unable to build program BUILD OUTPUT IntTreeTest.java:14: error: method evenBranches in class IntTree cannot be applied

Posted: Fri May 20, 2022 6:38 pm
by answerhappygod
Unable To Build Program Build Output Inttreetest Java 14 Error Method Evenbranches In Class Inttree Cannot Be Applied 1
Unable To Build Program Build Output Inttreetest Java 14 Error Method Evenbranches In Class Inttree Cannot Be Applied 1 (39.98 KiB) Viewed 32 times
Unable To Build Program Build Output Inttreetest Java 14 Error Method Evenbranches In Class Inttree Cannot Be Applied 2
Unable To Build Program Build Output Inttreetest Java 14 Error Method Evenbranches In Class Inttree Cannot Be Applied 2 (40.87 KiB) Viewed 32 times
Please help me fix my code!!!! Thanks
Unable to build program BUILD OUTPUT IntTreeTest.java:14: error: method evenBranches in class IntTree cannot be applied to given types; assertEquals(new GoodIntTree(s).evenBranches(), new IntTree(s).evenBranches()); required: IntTreeNode found: no arguments reason: actual and formal argument lists differ in length IntTreeTest.java:30: error: method evenBranches in class IntTree cannot be applied to given types; assertEquals(new GoodIntTree(s).evenBranches(), new IntTree(s).evenBranches(); A required: IntTreeNode found: no arguments reason: actual and formal argument lists differ in length 2 errors

public class IntTree { private IntTreeNode overallroot; public int countEvenBranches() { return evenBranches (overallRoot); } public int evenbranches (IntTreeNode root) { if (root == null) { return; } else if (root.data % 2 == 1 || root.left == null && root.right == null) { return evenBranches (root. left) + evenBranches (root.right); } else { return 1 + evenBranches (root. left) + evenBranches (root.right); } public static void main(String[] args) { System.out.println(new IntTree("[2 [8 [0] null] [1 [7 [4] null] [6 null [9]]]]").countEvenBranches());