Discussion Board
Go to the previous messageGo to the following message
Current Forum: Homework 6 - Part II
Date: Fri Dec 7 2001 1:30 pm
Author: Dozzi, Giancarlo <gdozzi@andrew.cmu.edu>
Subject: Re: -->getClone()

Yes, I also had this problem, and figured it out. I had a two dimensional array of Space objects called "spaces" in MyBoard. Keep in mind, that the variable spaces points to the array object (it's not primitive). When I created a new MyBoard, say [MyBoard clone = new MyBoard()], I had [clone.spaces = this.spaces]. The problem with that is that now the MyBoard object called "clone" had a direct pointer to the spaces in the cloned board (the one that got copied), so whenever spaces was modified in the "clone" object, it also modified the old (cloned) object. Hope this helps, feel free to contact me if you need to.

-Giancarlo Dozzi
Post response

Go to the previous messageGo to the following message
Current Thread Detail:
makeClone()      White, David      Tue Dec 4 2001 4:04 pm       
-->getClone()      White, David      Tue Dec 4 2001 4:28 pm       
Copy array      Scherer, Sebastian      Thu Dec 6 2001 1:58 pm       
Re: -->getClone()      Dozzi, Giancarlo      Fri Dec 7 2001 1:30 pm       
Whoops      Dozzi, Giancarlo      Fri Dec 7 2001 2:37 pm       
Re: Whoops      White, David      Fri Dec 7 2001 2:43 pm       
Re: Whoops      Chen, Richard      Tue Dec 11 2001 1:03 am       

Back to previous screen