/tutorial/external/Java/CSimple.java

http://github.com/tybor/Liberty · Java · 91 lines · 51 code · 27 blank · 13 comment · 0 complexity · f069d579fba58f1f6d6c5b1011e3ac45 MD5 · raw file

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