/tutorial/external/Java/CSimple.java
Java | 91 lines | 51 code | 27 blank | 13 comment | 0 complexity | f069d579fba58f1f6d6c5b1011e3ac45 MD5 | raw file
1/* CSimple.java */ 2 3import example5._any; 4import example5.example5; 5 6class CSimple 7{ 8 9 public static void main( java.lang.String[] args ) 10 { 11 12// initialize the Eiffel runtime 13 14 java.lang.String a[] = new java.lang.String[0]; // no command line args 15 _any._initialize_eiffel_runtime( a ); 16 17// create an instance of example5 18 19 example5 theE = new example5(); 20 21// note that the Eiffel creation procedure has not been called, and that 22// Eiffel object attributes can be read and written from Java 23 24 System.out.println( "value of example5.eiffel_integer: " + theE.eiffel_integer ); 25 theE.eiffel_integer = 2; 26 System.out.println( "value of example5.eiffel_integer: " + theE.eiffel_integer ); 27 28// now call the Eiffel creation procedure 29 30 theE.make(); 31 System.out.println( "value of example5.eiffel_integer: " + theE.eiffel_integer ); 32 33// create an instance of CSimple 34 35 CSimple csimple = new CSimple(); 36 37// call the proc1 procedure with argument 13 38 39 csimple.proc1( theE, 13 ); 40 System.out.println( "value of example5.eiffel_integer: " + theE.eiffel_integer ); 41 42// call the proc1 procedure with argument -11 43 44 csimple.proc1( theE, -11 ); 45 System.out.println( "value of example5.eiffel_integer: " + theE.eiffel_integer ); 46 47// call the proc2 procedure with argument 13 48 49 csimple.proc2( theE, 103 ); 50 System.out.println( "value of example5.eiffel_integer: " + theE.eiffel_integer ); 51 52// call the proc2 procedure with argument -11 53 54 csimple.proc2( theE, -101 ); 55 System.out.println( "value of example5.eiffel_integer: " + theE.eiffel_integer ); 56// 57 System.out.println( "main() in CSimple ended." ); 58 } 59 60 public CSimple() 61 { 62 } 63 64 65 public void proc1( example5 theE, int i ) 66 { 67 try 68 { 69 theE.proc1( i ); 70 } 71 catch ( java.lang.Exception e ) 72 { 73 System.out.println( "Exception was thrown: " + e.getMessage() ); 74 } 75 } 76 77 public void proc2( example5 theE, int i ) 78 { 79 try 80 { 81 theE.proc2( i ); 82 } 83 catch ( java.lang.Exception e ) 84 { 85 System.out.println( "Exception was thrown: " + e.getMessage() ); 86 } 87 } 88 89} 90 91/* End of file */