Alice Community  

Go Back   Alice Community > Alice 3 > How Do I?

Reply
 
Thread Tools Display Modes
Color returned from .getColor is inconsistent
Old
rfgrove
Guest
 
Status:
Posts: n/a
Default Color returned from .getColor is inconsistent - 02-08-2010, 11:23 AM

I'm writing Java code to manipulate geometric shapes in Alice 3. The code sets the color of each shape. My expectation was that the method getColor() would return a reference to the Color constant that was used to set the color, but it returns a different object each time it's called. Can anyone explain what these different Color objects are and why they're not the same?

MyTriangle tri = new MyTriangle();
tri.setColor(Color.BLUE);
System.out.println(Color.BLUE);
for (int i=0; i<3; i++) {
System.out.println(tri.getColor());
}

org.alice.apis.moveandturn.Color@77eaf8
org.alice.apis.moveandturn.Color@e35bb7
org.alice.apis.moveandturn.Color@9a8a68
org.alice.apis.moveandturn.Color@1f4e571

Last edited by rfgrove; 02-08-2010 at 11:25 AM.
   
Reply With Quote
Old
jediaction
Senior Member
 
jediaction's Avatar
 
Status: Offline
Posts: 5,064
Join Date: Jul 2009
Location: Bel Air, Maryland
Default 02-08-2010, 11:40 AM

I am not exactly sure but I have Alice 3 and you cannot have 2 objects the same. If this is in an if/else statement, it should work but also, you could have a little mess up in the code an it wont work. I have noticed that the code is messed up but im trying to figure out what is messed up...hold on, i dont udner stand line 4 of the code


Website: www.salokingames.com
FaceBook: www.facebook.com/SalokinGames

Last edited by jediaction; 02-08-2010 at 12:00 PM.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.