Hi
I don't have so much experience in OOP, but I'm trying to program a moderately complex game in Processing. It is not my first in Processing, but it is my first serious project.
I am having a recurring problem that I can't explain. I'm not copy-pasting all the code cause that's too long, so let me explain.
One of my arrayList, let's call it LIST, is modified dynamically by adding elements at some moments in the game. Actually, each time it is augmented by the current configuration of the game (a special class containing the current configuration, a variable that i call CONFIG - I write in caps to distinguish from my text here -).
Problem: When I try to come back to a previous configuration, the program actually calls the current value of CONFIG, and not the old one when it was supposed to be stored in LIST at that moment. As if what I was putting in LIST was not the actual value of CONFIG, but the address of the variable itself...I clearly checked in my program that the only moments where LIST is modified is by a .add method (no .set methods), so I don't think it is a mistake from me.
Sorry for the abstract explanations, I hope I made myself clear. I see really no way out of this.
I don't have so much experience in OOP, but I'm trying to program a moderately complex game in Processing. It is not my first in Processing, but it is my first serious project.
I am having a recurring problem that I can't explain. I'm not copy-pasting all the code cause that's too long, so let me explain.
One of my arrayList, let's call it LIST, is modified dynamically by adding elements at some moments in the game. Actually, each time it is augmented by the current configuration of the game (a special class containing the current configuration, a variable that i call CONFIG - I write in caps to distinguish from my text here -).
Problem: When I try to come back to a previous configuration, the program actually calls the current value of CONFIG, and not the old one when it was supposed to be stored in LIST at that moment. As if what I was putting in LIST was not the actual value of CONFIG, but the address of the variable itself...I clearly checked in my program that the only moments where LIST is modified is by a .add method (no .set methods), so I don't think it is a mistake from me.
Sorry for the abstract explanations, I hope I made myself clear. I see really no way out of this.
1