MATLAB BUILDER JA 2 Podręcznik Użytkownika Strona 27

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 292
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 26
Example: Magic S quare
System.out.println("Magic square of order " + n.toString());
/* Create new magic object */
theMagic = new magic();
/* Compute magic square and print result */
result = theMagic.makesqr(1, n);
System.out.println(result[0]);
}
catch (Exception e)
{
System.out.println("Exception:"+e.toString());
}
finally
{
/* Free native resources */
MWArray.disposeArray(n);
MWArray.disposeArray(result);
if (theMagic != null)
theMagic.dispose();
}
}
}
In th is sam pl e application, the following code imports the librarie s and
classes that a re needed:
import com.mathworks.toolbox.javabuilder.*;
import magicsquare.*;
The following line instantiates the magic class:
theMagic = new magic();
The following line ca lls the makesqr method:
result = theMagic.makesqr(1, n);
In this method call, the first input argument specifies the number of
outputs the method is to return. This input is equivalent in value to the
1-19
Przeglądanie stron 26
1 2 ... 22 23 24 25 26 27 28 29 30 31 32 ... 291 292

Komentarze do niniejszej Instrukcji

Brak uwag