This site requires JavaScript, please enable it in your browser!
Greenfoot back
Jaimie
Jaimie wrote ...

2014/2/16

exercise 6.1

Jaimie Jaimie

2014/2/16

#
How do I create a new body that is a different color and size. I keep getting an error in the box.
danpost danpost

2014/2/16

#
What (exactly) are you entering in the field input boxes (and specify what each field calls for (shown to the right of each field input box) ?
Jaimie Jaimie

2014/2/16

#
It asks for new Body ( , inrsize , double mass , Vector movement ) Color color And no matter what I put in it has an error
danpost danpost

2014/2/16

#
I know that for the color, you need to use 'java.awt.Color.COLOR_NAME' or 'new java.awt.Color(int, int, int)'. You will probably also need to use 'new Vector(int, int)' or something like that.
Jaimie Jaimie

2014/2/16

#
The table pops up when I want to create another body
danpost danpost

2014/2/16

#
danpost wrote...
What (exactly) are you entering in the field input boxes ...?
Jaimie Jaimie

2014/2/16

#
Numbers and a color is that wrong?
danpost danpost

2014/2/17

#
Jaimie wrote...
Numbers and a color is that wrong?
That depends on exactly how you are typing them in!
tersc tersc

2014/4/26

#
I have the same issue, example for a new body(123 #int size 666 #double mass (2, 3.0 ) # Vector Movement (255,120,120) # Color, but with for instancea color like blue doesn't work
danpost danpost

2014/4/26

#
Ok, I see what is going on; but, trying to explain it might prove difficult. The color part is easy -- for blue, use 'java.awt.Color.blue' -- for a new color, use 'new java.awt.Color(255, 120, 120)' The window is not part of your program, in itself, and it does not have the packages accessible to it. Therefore, you must specify them (as with the color example above). If there are other input fields you are having trouble with, post what is expected with what you are trying and I will try to help.
tersc tersc

2014/4/26

#
Thanks danpost. I seem to be left with a problem on the Vector movement. My input is now new body(123 #int size 666 #double mass (2.2, 3.1 ) # Vector Movement new java.awt.Color.blue and I get the message: Error:')' expected As the Vector is the only input with ( or ), it must be this, or am I wrong?
danpost danpost

2014/4/26

#
You will probably need to use 'new java.util.Vector(2.2, 3.1)' (if you are using the java.util.Vector class); or, 'new Vector(2.2, 3.1)' if you are using your own Vector class.
You need to login to post a reply.