Skip to content

Commit

Permalink
callback
Browse files Browse the repository at this point in the history
  • Loading branch information
nglthu committed Mar 7, 2024
1 parent 94292de commit fae9221
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 31 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/mycompany/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
import com.mycompany.app.Sequence.SequenceA;
import com.mycompany.app.Sequence.SequenceAnonymous;
import com.mycompany.app.Sequence.SelectorA;
import com.mycompany.app.Callback.Caller;
import com.mycompany.app.Callback.Callee;
import com.mycompany.app.Callback.CallerTest;
import com.mycompany.app.Callback.CalleeTest;


import com.mycompany.app.Node.*;
Expand Down Expand Up @@ -189,10 +189,10 @@ public static void main(String[] args) {

//Test callback

Callee cee = new Callee();
Caller cer = new Caller(cee);
System.out.println("test call back");
cer.go();
CalleeTest cee = new CalleeTest();
CallerTest cerA = new CallerTest(cee);
System.out.println("test call back"+ cerA);
cerA.go();



Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mycompany.app.Callback;

public class Callee implements IncreamentableInterface{
public class CalleeTest implements Increment{
private int i=0;
void incrementMethod(){
public void inMeth(){
i++;
System.out.println("Callee with i"+i);

Expand Down
17 changes: 0 additions & 17 deletions src/main/java/com/mycompany/app/Callback/Caller.java

This file was deleted.

19 changes: 19 additions & 0 deletions src/main/java/com/mycompany/app/Callback/CallerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.mycompany.app.Callback;

public class CallerTest {
private Increment callBackRef;
CallerTest(){}

public CallerTest(Increment ref){
callBackRef = ref;

}
public void go(){
System.out.println("test"+callBackRef);
((CalleeTest) callBackRef).inMeth();


}


}

This file was deleted.

6 changes: 6 additions & 0 deletions src/main/java/com/mycompany/app/Callback/Increment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mycompany.app.Callback;

public interface Increment {
void inMeth();

}

0 comments on commit fae9221

Please sign in to comment.