They don’t need to be used together, technically they’re not required however it’s good practise and they do have benefits. Getters have the same benefit as setters in that you can apply validation. Setters will check the user input and make sure it’s what you want before adding it, however what if there’s an error somewhere in the code that changes the property directly? The getter can have similar validation put on it to return a specific error message to the console if the property doesn’t have the type of data you want in it. Therefore you know the source of the issue and can find out where the problem is coming from.
A getter I would say has less direct benefits than a setter as ideally the property will not be changed without the setter, thus your validation should hold. However it’s still worth having so that you can use the same call whether you’re getting or setting a value eg. robot.numOfSensors
is a getter, robot.numOfSensors = 100
is a setter.