Home| Progetto| Web| Faq| Acronimi | ||||
Argomenti Documenti pubblicabili:1120
Scripts:1282 Documenti non pubblicabili:162 Categorie tematiche:68 .Net |_C# |_Visual basic.net |_Asp.net Active Server Pages C++ Cascade Style Sheet JavaScript Mysql Php Xml Java |_Java 2 Micro Edition |_Java server pages |_Java Servlet Oracle |_PLSQL PostgreSQL Unix
Java 2 Micro Edition...
Info:
startApp() , pauseApp(), destroyApp()
Oracle...
Script:
Opzione DEFAULT per il valore di una colonna
Unix...
Tip:
How remove a file named -r
PLSQL...
Script:
Esempio inserimento righe all'interno di un loop
Shell scripting...
Script:
Ciclo sul contenuto directory
A User Agent, like a web browser, uses HTTP to request a HTML document
Php Funzione mail()
In programming the danger of exploring the small details of coding is that you get obsessed with every line of code you write, thereby greatly reducing productivity.
In general, is not worth obsessing over code. On the other hand you should code with deliberation and intent. Steven Feurstein Oracle Magazine July /August 2004 A User Agent, like a web browser, uses HTTP to request a HTML document
|
Java 2 Micro Edition
Home >Java 2 Micro Edition > Un midlet per estrarre numeri vincenti
ObiettiviIl seguente codice rappresenta la luckLottoNumebrs che ha la funzione di:
PrerequesitiConoscenzePer questo tutorial occorre una conoscenza di base del linguaggio Java, e della conoscenza dell'ambiente di sviluppo (Jdk). Per compilare e preparare il codice dell'applicazione è necessario installare Java 2 Standard Edition versione del jdk 1.5.0 o più recente propriamente integrata con il J2ME Wireless Toolkit.Per il download e l'installazione delle applicazioni java nel cellulare è stato utilizzato MIDway_2_8 ma esistono altri progammi e strumenti altrettando funzionali. Per l'installazione e l'esecuzione del programma sul telefono cellulare è necessario disporre di un cellulare con la Java Virtual Machine e dei necessari strumenti per consentire il trasferimento del programma dal Pc (collegamento bluetooth, cavo usb). In questo esempio è stato utilizzato un Motorola E1000 con le seguenti caratteristiche:
MidletIl codice della midlet è il seguente: /* * @(#)luckyLottoNumbers.java 2003-11-12 Roma fishScript.com /* luckyLottoNumbers richiede CLDC 1.1 */ import javax.microedition.lcdui.*; import javax.microedition.midlet.*; import java.util.Random; public class luckyLottoNumbers extends MIDlet implements CommandListener { private Display display; private Form mForm; // dichiarazione metodi private boolean numberValidation; private int elaborateRandom; // commandi base private final Command cExit = new Command("Exit", Command.SCREEN, 1); private final Command cRedoIt = new Command("Estrai", Command.SCREEN, 0); Random randomNum = new Random(); //****************************** //***impostazioni**** // gruppi di n interi private int gl = 6; // numero serie private int sl = 5; // esempio ->enalotto -> 1-90 private int minNum = 1; private int maxNum = 90; //****************************** //****************************** // variabili di lavoro variables // intero pseudorandom private int r; private String st; private String sp; int luckyNum; String strLuckyNum; //****************************** // intero estratti int[] extractedLuckyNum = new int[gl]; int c = 0; // public luckyLottoNumbers() {} public void startApp() { generateNumbers(); mForm.append("Impostazioni:\n" + sl + " gruppi di " + gl + " interi " + "\n" + "da: " + minNum + " a " + maxNum ); Display.getDisplay(this).setCurrent(mForm); mForm.append(new StringItem(null, "\nBuon fortuna \n")); mForm.append(new StringItem(null, "Quando vinci non dimenticare fishScript.Com!")); // Exit mForm.addCommand(cExit); // RedoIt mForm.addCommand(cRedoIt); mForm.setCommandListener(this); } public void generateNumbers(){ mForm = new Form("LuckyNumbers Generator"); for(int m=0; m < sl ;m++){ c=0; while(true){ // metodo nextInt(int n) da CLDC 1.1 luckyNum = elaborateRandom(maxNum); // if the number is valid if (numberValidation(luckyNum)){ // memorizzare gli interi pseudoramndom number in un array extractedLuckyNum[c] = luckyNum; c++; } if (c==gl){ //ordinamento array -> buble sorting bubbleSort(extractedLuckyNum); // stampa sequenze for(int v=0; v < extractedLuckyNum.length;v++){ // il look della stampa if(extractedLuckyNum[v]<10 ){sp = " ";}else {sp = "";} st = sp + extractedLuckyNum[v] + "|" ; mForm.append(new StringItem(null, st )); } mForm.append(new StringItem(null, " \n" )); break;} } } } // restituisce true se l'intero è valido public boolean numberValidation(int n){ if (n<minNum){return false;} for(int i=0; i < extractedLuckyNum.length;i++){ if (extractedLuckyNum[i]==n){return false;} } return true; } // pseudorandom public int elaborateRandom(int n){ r = randomNum.nextInt(n+1); //r = r++; // no zero allowed return r; } //ordinamento array public static void bubbleSort(int[] a){ for (int i =a.length-1; i>0;i--){ //System.out.println(); //System.out.println(); for (int y=1;y<=i; y++){ if (a[y-1] >a[y]) swap(a,y-1,y); } } } public static void swap(int[] a,int i,int y){ if (i == y) return; int temp = a[y]; a[y] = a[i]; a[i] = temp; } // comandi public void commandAction(Command c, Displayable s) { // exit if (c == cExit) { destroyApp(false); notifyDestroyed(); return; } // estrai if (c == cRedoIt) {startApp(); return;} } public void pauseApp() {} public void destroyApp(boolean unconditional) {} } ![]() Verificato il corretto funzionamento della Midlet, è possibile creare e trasferire il package jar nel dispositivo mobile. Warning: include(ads/text468x15.html): failed to open stream: No such file or directory in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131 Warning: include(): Failed opening 'ads/text468x15.html' for inclusion (include_path='.;C:\php\pear') in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131 Tutorial ![]() ![]() ![]() ![]() ![]() ![]() ![]() Script ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Comandi ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Cerca
Java 2 Micro Edition...
Info:
startApp() , pauseApp(), destroyApp()
Anger is creative, depression is useless.
Dyson, Freeman J. Anger is creative, depression is useless.
Dyson, Freeman J.
Java 2 Micro Edition...
Info:
startApp() , pauseApp(), destroyApp()
Java 2 Micro Edition...
Definizioni:
Canvas
Oracle...
Definizioni:
Scalar Subquery
Shell scripting...
Script:
Looping samples
fishScript.Com is accessible by Mobile access technology
as mobile phones, Palm and Pocket PC .
Nicoleta e Marco Magnani tutorial, examples, courses, esempi, corsi, esercizi, appunti vari Dottoressa Nicoleta Dragu Formatrice Docente Insegnante Mediatrice Culturale Dott. Marco Magnani Universita La Sapienza Roma Master Computer Science Hunter College New York , Data Base Administrator DBA oracle System architect |