0

I would like to test if a Specified Method exists. And I have done the programmation with some help from this website. Yeah, I have written 2 interfaces and a class who implement the interfaces.

Here are parts of the codes:

public class TestMethod extends AbstractNcssCountRule implements UpSearch,
    JudgeResult {

    public Object search(ASTMethodDeclaration node, Object data) {
        return super.visit(node, data);
    }

    public Object judge(ASTMethodDeclaration node, Object data) {
        if ((node.jjtGetChild(1) instanceof ASTMethodDeclarator && ( node
            .jjtGetChild(1)).getImage().equals("isDirty"))) {
            System.out.println("There it is.");
        }
    }
}

However,there is a small bug. When I move my cursor to the name of the class, it tells: Implicit super constructor AbstractNcssCountRule() is undefined for default constructor. Must define an explicit constructor

Esct
  • 133
  • 1
  • 2
  • 13

2 Answers2

2

You have to implement all the methods from both the interface

  • More details? I don't understand. – Esct Jun 11 '13 at 13:44
  • I have writeen 2 interfaces. – Esct Jun 11 '13 at 13:45
  • In fact I have implemented all the methods. I think. – Esct Jun 11 '13 at 13:50
  • check your code that you have implemented all the methods of both interface in your Class "TestMethod" –  Jun 11 '13 at 14:11
  • the 2 interfaces are package com.chanbarry.pmd; public interface UpSearch { public Object search(); } package com.chanbarry.pmd; public interface JudgeResult { public Object judge(); } – Esct Jun 11 '13 at 14:20
  • I think I have implemented the 2 interfaces. – Esct Jun 11 '13 at 14:23
  • Buddy, your methods in interface are non-parameterized. and you are implementing parametrized methods in your class. edit your interface code and specify a proper parameters to your methods that you are going to use in your class. –  Jun 11 '13 at 14:38
  • then try defining a default constructor or parameterized constructor with some arguments. –  Jun 11 '13 at 15:31
  • sorry i don't really understand. – Esct Jun 12 '13 at 07:51
  • "The type TestMethod must implement the inherited abstract method Rule.hasProperty(String)." – Esct Jun 12 '13 at 09:15
0

It's the problem of Version. Just delete one version and modify the codes a little.

Esct
  • 133
  • 1
  • 2
  • 13