|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: May 2006
Città: Salerno
Messaggi: 936
|
[Java] confronto sorgenti
vorrei provare a confrontare i nostri stili di scrittura del codice
non solo l'indentazione, anche (ad esempio) l'uso di break e continue, l'uso di classi anonime e così via... per questo serve un qualcosa da scrivere... io avevo pensato ad un hash o ad una queue... void cosa ne pensate? |
|
|
|
|
|
#2 | |
|
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Quote:
![]() E non ho capito cosa c'entra un hash con lo stile di scrittura.
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
|
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: May 2006
Città: Salerno
Messaggi: 936
|
Quote:
una specie di scambio culturale Ultima modifica di AngeL) : 26-08-2007 alle 20:29. |
|
|
|
|
|
|
#4 | |
|
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Quote:
Si stabilisce un argomento/problema preciso e si vede come ognuno ha scritto il sorgente. Il problema è solo la scelta di cosa fare ....
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
|
|
|
|
|
|
#5 | |
|
Senior Member
Iscritto dal: May 2006
Città: Salerno
Messaggi: 936
|
Quote:
appunto.. tu cosa proponi? |
|
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
L'ultima volta che ho usato continue è stato nella primavera del '24.
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#7 |
|
Senior Member
Iscritto dal: May 2006
Città: Salerno
Messaggi: 936
|
|
|
|
|
|
|
#9 |
|
Senior Member
Iscritto dal: May 2006
Città: Salerno
Messaggi: 936
|
|
|
|
|
|
|
#10 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
|
|
|
|
|
|
#11 |
|
Senior Member
Iscritto dal: May 2006
Città: Salerno
Messaggi: 936
|
|
|
|
|
|
|
#12 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
O' signur. Ve lo do io qualcosa da fare. Devo fare l'interfaccia per un record che avrà trenta milioni di campi. Mi ci vuole uno schermo a 640x20218 perchè si veda tutta. Requisiti utente: deve avere quattro cervelli per riuscire a restare attento mentre immette tutti i dati che servono.
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#13 | |
|
Senior Member
Iscritto dal: May 2006
Città: Salerno
Messaggi: 936
|
Quote:
![]() edit: servirà anche un HD da 20 TB
Ultima modifica di AngeL) : 26-08-2007 alle 23:32. |
|
|
|
|
|
|
#14 |
|
Senior Member
Iscritto dal: May 2006
Città: Salerno
Messaggi: 936
|
allora, proviamo?
da dove lo pigliamo st'esercizio? ![]() edit: e se provassimo a fare tutti insieme (yuppiii) un progetto in swing? Ultima modifica di AngeL) : 27-08-2007 alle 10:49. |
|
|
|
|
|
#15 |
|
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Beh, di possibilità ce ne sono infinite. Alcune che mi vengono in mente:
- Realizzare un programma (console o gui) che data una directory in input, faccia una statistica di tutto il sotto albero di directory: numero di file, totale dimensione dei file, ecc.... - Realizzare un programma gui che consenta di fare conversioni tra unità di misura (quali unità, lo si stabilisce a priori). - Realizzare un programma gui che permetta di scegliere un file e quindi computare diversi hash sul file es. MD5, SHA-1 (se non sbaglio ci sono già, almeno nelle ultime release di Java, dei provider appositi per questi digest). - Realizzare un programma gui per il famoso gioco dei "15", fatto con i numeri o anche con immagini. - Realizzare un programma per gestire una semplice chat di tipo client-server. Un server riceve i messaggi da un client e li "gira" verso tutti gli altri client. Questo già presuppone un discreta conoscenza del networking.
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
|
|
|
|
|
#16 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Se si fa senza gui è possibile confrontare diversi linguaggi
Io sinceramente pensavo a qualcosa di più breve... |
|
|
|
|
|
#17 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
I GUI framework sono più omogenei di quanto non si possa sospettare. Comunque, riciclo un'idea. Riconoscimento ottico di un'informazione contenuta in un'immagine a colori.
Cioè impacchettare informazioni in un'immagine e leggere le stesse informazioni da una scansione di quell'immagine (ad esempio l'immagine da "leggere" potrebbe essere la fotografia del display di un cellulare).
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#18 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Ma sono cose lunghe (che tra l'altro ho già fatto). Io credevo che AngeL) si riferisse di più allo stile di scrittura del codice e non alla bravura nell'implementare un certo esercizio.
|
|
|
|
|
|
#19 | |
|
Senior Member
Iscritto dal: May 2006
Città: Salerno
Messaggi: 936
|
Quote:
ah, visto che non avevo niente da fare, ho fatto l'hash perchè non iniziamo con questo, che è piu' veloce da fare? questo è il mio Codice:
public class Hash<K, V> {
private static int DEFAULT_MAX_ELEMS = 100;
static public class KeyAlreadyExistsException extends RuntimeException {
KeyAlreadyExistsException(String key) {
super("Key already exists in the hash : " + key);
}
}
static public class KeyNotFoundException extends RuntimeException {
KeyNotFoundException(String key) {
super("Can't find key : " + key);
}
}
static public class HashIsFullException extends RuntimeException {
HashIsFullException() {
super("The hash is full");
}
}
protected int MAX_ELEMS;
protected Object[] values;
protected Object[] keys;
protected int elemcount;
/**
* Instantiates a new Hash.
* @param MAX_ELEMS The maximum number of elements this hash can hold.
*/
public Hash(int MAX_ELEMS) {
elemcount = 0;
this.MAX_ELEMS = MAX_ELEMS;
values = new Object[MAX_ELEMS];
keys = new Object[MAX_ELEMS];
}
public Hash() {
this(DEFAULT_MAX_ELEMS);
}
/**
* Looks for an object in the hash.
* @param key The key associated to the value to find
* @throws KeyNotFoundException
* @return The object associated with key*/
public V find(K key)
throws KeyNotFoundException {
return (V)values[indexOfKey(key)];
}
/**
* Adds a value to the hash.
* @param key The key representing the value to add
* @param value The value to add to the hash
* @throws KeyAlreadyExistsException
* @throws HashIsFullException*/
public void add(K key, V value)
throws HashIsFullException, KeyAlreadyExistsException {
if(keyAlreadyExists(key)) throw new KeyAlreadyExistsException(key.toString());
int nextFree = nextFreeIndex();
keys[nextFree] = key;
values[nextFree] = value;
elemcount++;
}
/**
* Removes a value from the hash and returns it.
* @param key The key representing the value to remove
* @throws KeyNotFoundException
* @return The value or null if the key isn't associated to a value*/
public V remove(K key)
throws KeyNotFoundException {
int i = indexOfKey(key);
V ret;
elemcount--;
keys[i] = null;
ret = (V)values[i];
values[i] = null;
return ret;
}
/**
* Replaces a key with another one.
* @param oldKey The key to replace
* @param newKey The new key
* @throws KeyAlreadyExistsException
* @throws KeyNotFoundException*/
public void changeKey(K oldKey, K newKey)
throws KeyAlreadyExistsException, KeyNotFoundException {
int i = indexOfKey(oldKey);
if(oldKey.equals(newKey)) return;
if(keyAlreadyExists(newKey)) throw new KeyAlreadyExistsException(newKey.toString());
keys[i] = newKey;
}
/**
* Replaces a value with another one.
* @param key The key representing the value to change
* @param newValue The new value
* @throws KeyNotFoundException
*/
public void changeValue(K key, V newValue)
throws KeyNotFoundException {
values[indexOfKey(key)] = newValue;
}
/**
* Dumps the hash, printing pairs of keys and values.
*
*/
public void dump() {
for(int i = 0 ; i < MAX_ELEMS ; i++)
if(keys[i] == null && values[i] == null)
System.out.println("null: null");
else
System.out.println((K) keys[i] + ": " + (V) values[i] + "");
}
public boolean isFull() {
return elemcount == MAX_ELEMS;
}
private boolean keyAlreadyExists(K key) {
for(int i = 0 ; i < MAX_ELEMS ; i++)
if(keys[i] != null && keys[i].equals(key))
return true;
return false;
}
private int indexOfKey(K key)
throws KeyNotFoundException {
for(int i = 0; i < MAX_ELEMS ; i++)
if(keys[i] != null && keys[i].equals(key))
return i;
throw new KeyNotFoundException(key.toString());
}
private int nextFreeIndex()
throws HashIsFullException {
for(int i = 0 ; i < MAX_ELEMS ; i++)
if(keys[i] == null && values[i] == null)
return i;
throw new HashIsFullException();
}
}
|
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 23:29.













Si stabilisce un argomento/problema preciso e si vede come ognuno ha scritto il sorgente. Il problema è solo la scelta di cosa fare ....
e perchè?
turale? 








