Closed rayouyang closed 8 years ago
Please have a look at my comments on #54? I believe there are still improvements to be made.
Hey John,
So the current standing is that there is this function updateCurrentPosition -- which uses a few static variables that should be class specific. So when I initially tried to factor out this function, I assumed I would have to factor out the static variables involved with this function, the result was two options:
With these two options in mind, I opted to keep updateCurrentPosition as a unique subclass function ( even though yes it is true that they are all copy and pasted together) because of its static variables, If you have suggestions for factoring out this class while maintaining its static variables to be subclass specific please let me know, as of now my current evaluation is that updateCurrentPosition should be a class specific function.
Thanks,
Ray Ouyang
On Sun, Nov 13, 2016 at 9:44 PM, John Alexander notifications@github.com wrote:
Please have a look at my comments on #54 https://github.com/UCSB-CS56-Projects/cs56-games-country-runner/issues/54? I believe there are still improvements to be made.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/UCSB-CS56-Projects/cs56-games-country-runner/pull/65#issuecomment-260253196, or mute the thread https://github.com/notifications/unsubscribe-auth/AJQgplkzwS9oFrR3jVqVRisnsw0BYvLDks5q9_VagaJpZM4KvSo2 .
Ray, Your first approach is the correct one. You should make the variables non-static AND you should move them to the Obstacle class. Attributes like speed and occurrence are common to all Obstacles, so they should be in the superclass. THEN, you should change the constructor of each specific obstacle to set these variables to the specific values used in that class. This will probably also require that you make the variables protected instead of private.
Jack Alexander
On Mon, Nov 14, 2016 at 4:32 PM, Ray Ouyang notifications@github.com wrote:
Hey John,
So the current standing is that there is this function updateCurrentPosition -- which uses a few static variables that should be class specific. So when I initially tried to factor out this function, I assumed I would have to factor out the static variables involved with this function, the result was two options:
- I remove the static* part of the variable
- This results in the program failing to run which left me confused and the errors produced seemed like something beyond my scope of knowledge.
- I keep the variables static
- This resulted in each obstacle appearing simultaneously with the same speed and occurance ( these are some of the static variables that were supposed be kept class specific but when factored out become unanimous with all obsticles thus making their properties identical asides from the image)
With these two options in mind, I opted to keep updateCurrentPosition as a unique subclass function ( even though yes it is true that they are all copy and pasted together) because of its static variables, If you have suggestions for factoring out this class while maintaining its static variables to be subclass specific please let me know, as of now my current evaluation is that updateCurrentPosition should be a class specific function.
Thanks,
Ray Ouyang
On Sun, Nov 13, 2016 at 9:44 PM, John Alexander notifications@github.com wrote:
Please have a look at my comments on #54 https://github.com/UCSB-CS56-Projects/cs56-games-country- runner/issues/54? I believe there are still improvements to be made.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/UCSB-CS56-Projects/cs56-games-country- runner/pull/65#issuecomment-260253196, or mute the thread https://github.com/notifications/unsubscribe-auth/ AJQgplkzwS9oFrR3jVqVRisnsw0BYvLDks5q9_VagaJpZM4KvSo2 .
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/UCSB-CS56-Projects/cs56-games-country-runner/pull/65#issuecomment-260509548, or mute the thread https://github.com/notifications/unsubscribe-auth/AJQttA5JOWWb4M-PA8FSK3xjMP_lADQmks5q-P2jgaJpZM4KvSo2 .
Refactored obstacles (snail, raccoon, panda, sheep) into a parent class Obstacles to reduce the amount of copy and paste code.