Win a copy of Terraform in Action this week in the Cloud forum!

Thomas Crew

Greenhorn
+ Follow
since Nov 13, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Thomas Crew

Campbell Ritchie wrote:If you have the shapes all in the same array, you are implicitly grouping them together. You could have fields in each object which tell it where to go which direction to move in (provided to the constructor), and call a move() method



I thought of that but the array of 20 shapes are not all different from one another. So if I assigned fields to the object (if this is what you mean), wouldn't (for example) all the diamonds all move the same?

William O'Sullivan, yes this question is related to my previous post but i tried being more specific (Sorry if it seems like i'm posting the same topic twice). But no i'm not trying to code a asteroid game. Just a Graphicsprogram animation that displays a canvas with the said shapes moving and animating according to the stated rules/parameters.
8 years ago
Hi,
I'm trying to have each shape that's in the array move around the canvas randomly and independently. When the shape (array[i]) goes out of the canvas, it should be reset in another random location to continue moving once again. Can anyone tell me what's wrong with this code?

The "Driver" class draws the shapes from the class Star on to the canvas.






8 years ago

William Brogden wrote:Why should having the references to these polygons in an array make any difference?

How would you move a single polygon?

Bill



I'm not sure if i understand your questions correctly. If I wanted to move a single polygon i would call the method move() like array[i].move(x, y); or array[i].movePolar(r, theta) with "i" being an individual polygon in the array (so 1 of the 15 in aray[15]). I'm not sure how to call each polygon (array[1], array[2], array[3], ....) to move at the same time and differently in a loop
8 years ago
Hey,
I'm writing a program that displays an array of various GPolygons on a canvas. I want to have them to slowly move around the canvas independently from one another. The problem is that I'm unsure of how to have each polygons move differently and simultaneously since these 15 polygons are in a single array. I used polymorphism to create the different shape classes that extended to a common class. Then used a "driver" class to create an array of them and draw them on a canvas. Thanks for the help in advance!
8 years ago
Thanks A LOT Jayesh, you were completely right and now the "twinkling" works again! The way you explained the error made sense too. Appreciate it
8 years ago
Hi, I'm working on a program that displays different shapes on the canvas with a class called "Driver". I have a method called "toggle" that makes the shapes look like they're randomly twinkling by removing and then bringing back the visibility of a shape in the class called "Star". Unfortunately when i came back to work on the code today, the method "toggle" seems to not work anymore and i can't figure out what went wrong. My guess is i might have unintentionally removed a piece of code or when i added on more code i might've ruined the toggle method is someway. Can someone please help me out and see if you can find the problem? I have a feeling its something minuscule or obvious but i've just about given up on trying to figure it out myself!

Here:




8 years ago
Nevermind with the problem of repeating the first index position (i fixed that). Just still having trouble in figuring out what I specifically should change in the code (in changing the methods parameter from int to char)
9 years ago

Jeff Verdegan wrote:The method should return a char, not an int. And it should take a char as its parameter too. After all, its job is to turn on char into another char.



What would I specifically change in the code. When I change the int parameter to a char the program's output still doesn't work and now I'm noticing that the output is encrypting every character as "109" and adding them to one string. Example: "zz,," = "109109109109"


what i tried doing:


9 years ago

Greg Charles wrote:rotateCharacter() returns an int, so you are concatenating a series of ints to the "complete" String.



Thanks Greg.

If that's the problem, how would I translate the integers returned by the rotateCharacter() method in decrypt(), so its concatenating the encrypted/decrypted letters along with any unchanged numbers/symbols?
9 years ago
Hi everyone,
I've been working on a java program that decrypts and encrypts Rot-13 messages. The additional requirements for this program are that the program must only encrypt alphabetical letters (leave any other symbols, numbers, characters unchanged) and the methods within this program must be the ones I've used in the following code (along with the same parameters and signatures).
The problem i keep having is that when i run the program, the output is numerical for any character instead of producing the desired Rot-13 decryption. For example: when i input "zzz", the program outputs "109109109". I understand that its some how giving me the decimal number of its character but i don't know how i can fix (this is after 2 days of messing around with the code). I have a feeling the solution is something extremely simple (hopefully). However i'm unable to figure this out on my own at this point. If someone could read over this code and provide me with some kind of help, i would be really grateful :) .

-Thomas



9 years ago