Unable to build program BUILD OUTPUT IntTreeTest.java:14: error: method evenBranches in class IntTree cannot be applied
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Unable to build program BUILD OUTPUT IntTreeTest.java:14: error: method evenBranches in class IntTree cannot be applied
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());