Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Java design patterns

public abstract class Observer {
   protected Subject subject;
   public abstract void update();
}
Comment

Java design patterns

public class BinaryObserver extends Observer{

   public BinaryObserver(Subject subject){
      this.subject = subject;
      this.subject.attach(this);
   }

   @Override
   public void update() {
      System.out.println( "Binary String: " + Integer.toBinaryString( subject.getState() ) ); 
   }
}
Comment

Java design patterns

public class OctalObserver extends Observer{

   public OctalObserver(Subject subject){
      this.subject = subject;
      this.subject.attach(this);
   }

   @Override
   public void update() {
     System.out.println( "Octal String: " + Integer.toOctalString( subject.getState() ) ); 
   }
}
Comment

Java design patterns

public class HexaObserver extends Observer{

   public HexaObserver(Subject subject){
      this.subject = subject;
      this.subject.attach(this);
   }

   @Override
   public void update() {
      System.out.println( "Hex String: " + Integer.toHexString( subject.getState() ).toUpperCase() ); 
   }
}
Comment

Java design patterns

First state change: 15
Hex String: F
Octal String: 17
Binary String: 1111
Second state change: 10
Hex String: A
Octal String: 12
Binary String: 1010
Comment

PREVIOUS NEXT
Code Example
Java :: menu alert dialog in android 
Java :: new int[] java 
Java :: How to perform in-order traversal of a binary tree? 
Java :: spring swagger ui login oauth2 
Java :: android hide and show bottom navigation 
Java :: math.pow(x2-x1,2) 
Java :: java hashmap 
Java :: method 
Java :: array buffer 
Java :: arraylist methods in java 
Java :: java array 
Java :: instantiation in java 
Java :: join strings in java 
Java :: android videoview not smooth for mp4 
Java :: writeToFileAsync java 
Java :: log.d() andriod 
Java :: madrid 
Java :: set java time complexity 
Java :: how to set credentials for speechClient Java google api 
Java :: add image in loggin view spring boot security 
Java :: sum of no 
Java :: layout focus from recycleview not from top in fragment inside nestedScrollview in android xml 
Java :: tick mark android 
Java :: java arraylist max length 
Java :: netbeans how to get string from jcombobox 
Java :: implement elasticsearch filter in java 
Java :: linearview 2 items next to each other 
Java :: java program operations by classes and objects 
Java :: how to get data from array list to set java 
Java :: 8233*4 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =