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

2014/4/18

I am working on my project PoolTable game and can't figure out how to apply these things in my Work can please Help!!!!

bizzard bizzard

2014/4/18

#
– If the "l" key (lowercase ”L”) is pressed, then the PoolTable should be cleared of all Balls (but Pockets and the PowerBar should remain). Then, a file should be chosen using a FileDialog; this file specifies the number and position of new Balls to be placed into the (now empty) Pool Table. The format of this file is as follows: ∗ if the next (space delimited) character in the file is ’#’, then the rest of the current line should be ignored. ∗ if the next (space delimited) character in the file is ’B’, then the next three items in the file will be integers. The first represents a ball number, while the second and third represent the x and y locations of the ball. You may assume that all ball numbers will be between 0 and 15 (inclusively) and that no ball number will show up more than once. There is no guarantee that there will be any specific number of balls in the input file, though. – If the "s" key (lowercase ”S”) is pressed, then the current number and (integer) locations of each pool ball should be saved to a file, as chosen through a FileDialog. The format should match that of the "l" option above, to the extent that a file saved using this option should be able to be loaded using the "l" option. – If the "r" key (lowercase ”R”) is pressed, then all Balls currently on the table should be removed. You should then add all the Balls (15 playing Balls and the cue Ball) exactly as you should do in the constructor for a PoolTable.
concistency concistency

2014/4/22

#
Are you a student at Lindenwood? Because I think we are working on the same thing, I am stuck as well!
bizzard bizzard

2014/4/23

#
yes.... its really frustrating. its so unfair to have such a tough project for a computer science 1.
danpost danpost

2014/4/23

#
@bizzard, what have you tried? how far have you gotten? It appears that the basic thing in this assignment is creating formatted data and working with files; saving data that describes the position of the balls on the pool table (when the 's', for 'save', key is pressed); reading the file and restoring the position saved (when the 'l', for 'load', key is pressed); and, clearing the table and re-racking the balls (when the 'r', for 'reset', key is pressed). If you are wondering even how to start ... start by adding code in your world act method to detect the keystrokes and call some 'dummy' methods when the specific keys are detected. Then add code to those dummy methods to do what each is to do. Start with the easy one (the 'r' code); then, work on the other two. When you run into difficulty, then post what you have and ask for help. If the 'r' one can be done using 'l' with a specific file in mind, then you may want to do the others first.
concistency concistency

2014/4/23

#
I had to put mine in the "Ball" class in order to get the keystrokes first. I think that is why he put that comment that said "you may need to put code here depending on your code" in the world act() comments.
bizzard bizzard

2014/4/25

#
can you delete this post.. i got mine working now..
bizzard bizzard

2014/4/25

#
*******got it
You need to login to post a reply.