No sé por qué me da error aquí (estoy desesperado)

Yordigol
19 de Junio del 2009
Resulta que estoy programando un tad 'vehicle' y un tad 'garage' que almacena vehículos. Os pongo el código de los dos tads:


*** TAD VEHICLE***
import java.util.*;

public class Vehicle {
String matricula;
String marca;
String color;
int any;
boolean itv;
Date data_entrada;
float hora_entrada;
Date data_baixa;
float quota;
String descripcio;

Vehicle(String mat, String mar,String c, int anyo, boolean i, Date d_e, float h_e, Date d_b, float q, String d){
matricula=mat;
marca=mar;
color=c;
any=anyo;
itv=i;
data_entrada=d_e;
hora_entrada=h_e;
data_baixa=d_b;
quota=q;
descripcio=d;
}
String getPlateNumber(Vehicle v){
return v.matricula;
} /**método que devueluve la matricula*/

String getBrand(Vehicle v){
return v.marca;
}/**devuelve la marca*/

String getColour(Vehicle v){
return v.color;
}/**devuelve el color*/

int getRegistrationYear(Vehicle v){
return v.any;
}/**devuelve el anyo de matriculacion*/

boolean getITV_OK(Vehicle v){
return v.itv;
}/**devuelve si ha pasado la ITV*/

Date getDateIn(Vehicle v){
return v.data_entrada;
}/**devuelve fecha de entrada*/

float getTimeIn(Vehicle v){
return v.hora_entrada;
}/**devuelve hora de entrada*/

Date getDateExpired(Vehicle v){
return v.data_baixa;
}/**devuelve fecha de baja*/

float getMonthlyFee(Vehicle v){
return v.quota;
}/**devuelve cuota mensual*/

String getDescription(Vehicle v){
return v.descripcio;
}/**devuelve descripcion*/

}


*** TAD GARAGE***

public class garage {
Vehicle coches[];
int num_coches;
int max;

garage(int n){
coches = new Vehicle[n];
num_coches=0;
max=n;
}/**metodo constructor que crea un garage con capacidad para n coches*/


void addVehicle(garage g, Vehicle v){
if (g.num_coches==g.max)
{
System.out.println("El garatge està ple.");
}
g.coches[g.num_coches +1 ]=v;
g.num_coches++;
}/**añade un vehiculo al garage si no está lleno y si lo está muestra mensaje por pantalla*/

Vehicle getVehicle(garage g, String matricula){
int i=0;
while ((getPlateNumber(g.coches[i])) != matricula){ ***ERROR***
i++;
}
if (i>g.max){
System.out.println("No hi ha cap vehicle amb aquesta matricula");
}
else{
return g.coches[i];
}

}/**devuelve el vehículo con matricula igual a 'matricula' y si no está muestra mensaje por pantalla*/
}

Me señala el error cuando llamo al método "getPlateNumber" diseñado en la clase "Vehicle" y no entiendo por qué. Espero que me podáis ayudar porque forma parte de las prácticas de una asignatura y no sé cómo arreglarlo. Muchas gracias

hanson
19 de Junio del 2009
HOLA ESTUVE REVISANDO TU CODIGO Y ESTA ALGO INCOMPLETO COMO POR EJEMPLO NO SE QUE ERROR TE DA Y CON RELACION A ESTA PARTE

Vehicle getVehicle(garage g, String matricula){
int i=0;
while ((getPlateNumber(g.coches[i])) != matricula){ ***ERROR***
i++;
}
if (i>g.max){
System.out.println("No hi ha cap vehicle amb aquesta matricula");
}
else{
return g.coches[i];
}

DEBERIAS PRIMERAMENTE VERIFICAR SU TU CLASE GARAGE NO ESTE EN NULO, DESPUES TENDRIAS QUE VERIFCAR SI EN TU CLASE GARAGE EXISTEN VEHICULOS, Y MEJOR SERIA QUE MODIFIQUES TU CLASE VEHICULO PARA QUE TODOS SUS ATRIBUTOS SEAN PRIVADOS Y LE IMPLEMENTES SUS GETTER Y SETTER.

ESPERO HABER SIDO DE AYUDA NOS VEMOS CHAOOOOOOOOO