Scopo
Restituisce l'oggetto contenuto nella posizione desiderata dell'array.
Sintassi
object obj = Array.getObject(Indice)
Argomenti
Indice | Posizione da cui leggere l'oggetto. Da 0 a Length - 1. |
Valore di ritorno
Viene restituito l'oggetto contenuto alla posizione richiesta dell'array.
Esempio di codice
// ****************************************************************
// Sposta l'ultimo piano della torre di sinistra a quella di destra
// ****************************************************************
public void Torre.LeftToRight()
{
//
if (this.Left.length() > 0)
{
Piano p = null //
//
p = this.Left.getObject(this.Left.length() - 1)
//
// Se in R c'è qualcosa devo verificare di poterlo mettere..
if (this.Right.length() > 0)
{
Piano p1 = null //
p1 = this.Right.getObject(this.Right.length() - 1)
//
// Posso mettere un piano sopra un altro solo se il valore è minore
if (p1.Valore < p.Valore)
{
return
}
}
//
this.Left.remove(this.Left.length() - 1)
//
this.Right.addObject(p)
//
this.Counter = this.Counter + 1
TorreDiHanoi.refresh(1, -1)
}
}
// Sposta l'ultimo piano della torre di sinistra a quella di destra
// ****************************************************************
public void Torre.LeftToRight()
{
//
if (this.Left.length() > 0)
{
Piano p = null //
//
p = this.Left.getObject(this.Left.length() - 1)
//
// Se in R c'è qualcosa devo verificare di poterlo mettere..
if (this.Right.length() > 0)
{
Piano p1 = null //
p1 = this.Right.getObject(this.Right.length() - 1)
//
// Posso mettere un piano sopra un altro solo se il valore è minore
if (p1.Valore < p.Valore)
{
return
}
}
//
this.Left.remove(this.Left.length() - 1)
//
this.Right.addObject(p)
//
this.Counter = this.Counter + 1
TorreDiHanoi.refresh(1, -1)
}
}
- Se l'indice è superiore alla lunghezza dell'array viene lanciata un'eccezione.
Ultima modifica: 25/10/2016 / Validità: da 9.1.4040