Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. main() {
  2.     Structimplementationklasse a = new Structimplementationklasse( new Struc() );
  3.     while( a.hasNext() ) {
  4.         a.getNext();
  5.     }
  6. }
  7.  
  8. public class Structimplementationklasse implements Seq {
  9.    
  10.     Structimplementationklasse( Struc struc ) {
  11.         this.struc = struc;
  12.     }
  13.    
  14.    
  15.     int i = 0;
  16.  
  17.     Struc struc;
  18.    
  19.     boolean hasNext(){
  20.         if (i < struc.size()) return true;
  21.         return false;
  22.     }
  23.    
  24.     int getNext(){
  25.         try{
  26.             return ( struc.get(i++) );
  27.         }
  28.         catch ( EmptyException e ){ return 0;}
  29.        
  30.     }
  31.    
  32.    
  33. }
  34.  
  35. public class Adapter {
  36.     Adapter( Seq seq ) {
  37.         m_seq = seq;
  38.     }
  39.     Seq m_seq;
  40.     boolean hasNext() {
  41.         return seq.hasNext();
  42.     }
  43.     int getNext() {
  44.         return seq.getNext();
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement