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

2013/3/10

Adding a message in the Breakout Scenario.

ddcook82 ddcook82

2013/3/10

#
I am trying to add a message to the paddle as part of an assignment. I get error messages. How are you supposed to enter the text to create a message?
danpost danpost

2013/3/10

#
Please be more specific. Is the message to be applied directly on the paddle or should it be a seperate Actor object that displays the message? What code have you tried? What error message are you getting?
ddcook82 ddcook82

2013/3/10

#
These are the instructions from the assignment. Right-click on the Paddle class to construct the “Paddle of Destiny,” an immovable blue force and the perfect ally. The width of the paddle should exactly match the width of the play area, it should have a daunting thickness, and the label is absolutely necessary icing on a substantial cake. (Feel free to create your own label.) Note that the label need not be attached to the paddle, because there is no need for the paddle to move at all. You can create a label by creating an instance of the Message class. (Hint: Enter java.awt.Color.BLUE as the color when you construct the object. Make sure to enter that value exactly, including capitalization.) I open the message class and message (String the Text) I want my message to be Winning! I I enter that it gives the message Error: '.' expected. So i figured I had to enter it as 'Winning!'. If I do that then the message is Error: Enclosed character literal. This is the first week I have done any of this, so I have no idea how I am supposed to enter the text.
danpost danpost

2013/3/10

#
OK. Your message is to be entered as a 'String' object. Strings are always enclosed inside a set of double-quotes, line this: "Winning!" That should get you further along.
ddcook82 ddcook82

2013/3/10

#
Thank you!
chris553 chris553

2013/3/10

#
I am assuming you are part of an online class :) just like me? You need to right click on message in the actor class and click on "new Message(String theText). You input needs to be "Paddle of Destiny" or whatever you want to input. The quotation marks are required.
ddcook82 ddcook82

2013/3/12

#
I am in an online class also. I got how to add the message, but not how to input the text so that it would work in the scenario. I do believe I will be asking a lot of questions during this term. = )
danpost danpost

2013/3/12

#
It is done basically the same way as when you create the message manually.
Message msg = new Message("Winning!");
This creates the object and holds it in a field called 'msg'; now you just need to add 'msg' into the world where you want it.
You need to login to post a reply.