Reemer
04-26-2012, 05:40 PM
I'm gonna look into this a little more. I'll take off the spoiler if I need help in a little bit.
Well I'm doing this vehicle rental project and I need to generate a unique ID for each vehicle. I know there's a unique ID generator for Java, but I need this simple one. The instructions say to just have an int ID and add one to it each time you make a new contract for the vehicles.
The vehicles are in different classes (CarContract, TruckContract, BikeContract) and they are all extending the AbstractContract abstract class. I have the int ID in the AbstractContract and I'm setting it with this method in each class:
@Override
public int setID(){
super.ID++;
return super.ID;
}
And I'm returning it with this code:
@Override
public int getID(){
return super.ID;
}
but the ID is always 1. Could anyone help?
Well I'm doing this vehicle rental project and I need to generate a unique ID for each vehicle. I know there's a unique ID generator for Java, but I need this simple one. The instructions say to just have an int ID and add one to it each time you make a new contract for the vehicles.
The vehicles are in different classes (CarContract, TruckContract, BikeContract) and they are all extending the AbstractContract abstract class. I have the int ID in the AbstractContract and I'm setting it with this method in each class:
@Override
public int setID(){
super.ID++;
return super.ID;
}
And I'm returning it with this code:
@Override
public int getID(){
return super.ID;
}
but the ID is always 1. Could anyone help?