Suppose I have two objects of PARKING class that are respectively P1 and P2. PARKING class have unique identifier (UUID). I also have an object of class CAR which its name is mycar.
My car is currently built in P1 and now wants to migrate to P2.
Here is some code:
public class PARKING {
public String ID = new String();
ID = UUID.randomUUID().toString();
CAR car;
public PARKING(CAR car) {
this.car = car;
}
public PARKING (){
}
}
public class CAR {
public int ID;
public String name = new String();
}
public static void main(String[] args) {
CAR mycar = new CAR();
PARKING P1 = new PARKING(mycar);
PARKING P2 = new PARKING();
}
}
Note that I don't want that P2 take mycar. I mean something like this P2.setCAR (P1.getCAR());
I want the car itself migrate from its current object which is P1 to another object which is P2.
I hope I have explained the problem clearly. Thanks in advance.