Advice needed :How to avoid duplicate code?

The only way I can think of doing that would be to make a function with a type of parameter, but the object types would need to be the same, but they are not...so you would need a new class, but from here it gets completely pointless...so I got nothing...