Up Previous Next

Let's implement the registration method:

import java.awt.*; 
import javax.swing.*; 

public class Client extends JFrame implements ClientInterface { 

  public Client() {
    this.setTitle("iceblox: client frame"); 
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    this.setSize(300, 200); 
    this.setVisible(true); 
  }   

  ServerInterface server; 

  public void registerWith(ServerInterface server) {
    this.server = server; 
    this.id = server.register(this);     
    System.out.println("I have registered, I have id: " + this.id); 
  } 

  int id = -1; 
}
We see that this generates a chain of changes, consistent with what has been said so far.


Up Previous Next