1 18 19 package org.objectweb.jac.samples.document; 20 21 24 25 public class Document { 26 27 28 public String [] lines; 29 30 31 public Document( String [] lines ) { 32 this.lines = lines; 33 } 34 35 36 public void printAll () { 37 for (int i = 0; i < lines.length; i++) 38 printLine( i ); 39 } 40 41 42 public void printLines (int startLine, int n) { 43 for (int i = startLine; i < n + startLine; i++) 44 printLine( i ); 45 } 46 47 48 public void printLine (int i) { 49 System.out.println( lines[i] ); 50 } 51 52 53 public void setLine( int number, String s ) { 54 lines[number] = s; 55 } 56 57 58 public void setLines( String [] lines ) { 59 this.lines = lines; 60 } 61 62 63 public int countLines() { 64 return lines.length; 65 } 66 67 68 public void test() { 69 System.out.println("-- Printing the first line"); 70 printLine(0); 71 System.out.println("-- Printing the lines 3 and 4"); 72 printLines(2,2); 73 System.out.println("-- Printing all the document"); 74 printAll(); 75 } 76 77 } 78 79 80 81 82 | Popular Tags |