Looks like our team has hit the wall I’m sure a lot of other teams have encountered, being able to successfully pass parameters into a command. I don’t think I need to post the full code, but being able to do something like as a bad example –
What happens is that the last instance of SpinShooter overrides and other instances of the command. A simple annoyance right now, in that we can create two instances of the underlying object with the different settings and map those, but it’s going to be a much bigger problem when trying to build out command groups with TurnAngle and DriveDastance type commands with values determined on the fly. Does someone have an example showing best practices in passing dynamic params to commands that they can share?
What do you mean by this? Are you attempting to claim that the argument of “25” is being used by the other instance of SpinShooter(the one receiving 50)? That’s not how Java works. Those are 2 distinct objects with no shared memory. If this is the behavior you’re seeing, then you most likely have those values being stored in your command class as a static member variable.
Please do share your full code, ideally via github. What you describe is not how it’s supposed to be working
I think you’re on to something, it’s these little hints as to why I love this community. I’ve been coding for 45 years, but only 5 weeks in Java ;). The variables in the Shooter look like they should be –
Yup, exactly. static means there’s exactly one instance of the variable scoped to the class (and shared by all instances). So non-static variables would be different for each instance of a class, which is what you want here. Static shouldn’t be the default state for member variables unless they’re effectively constants (static final is Java’s equivalent to C++'s const)