vendredi 29 avril 2016

NoSuchMethodException (Java Reflection)

A GUI ATM class has a button call swipe. When it is swipe, it should dynamically call a Card.class

The ATM class extends JFrame. It have an inner class call "Data".

I provided a link if you want to see the ATM code.

I am not allow to change the ATM code.

Here is my card class:

public class Card {

  public static ATM.Data swipe(ATM anATM){  
        return new ATM.Data(cardNumber, accountNumber, name, pinNumber);
  }

}

Here the main part of the swipe function:

 try {
        Method method = class_.getMethod("swipe", new Class[0]);
        Data data = (Data)method.invoke(null, new Object[0]);


    catch (NoSuchMethodException var8_12) {
        this.printToScreen("No Such method exception when swiping card.");
    }

The problem is the Card is not being acception.

Why do I get a NoSuchMethodException? What can I do to change this?

Link to ATM source code: http://ift.tt/248HjxE





Aucun commentaire:

Enregistrer un commentaire