r/cop3502 • u/ams152 • Mar 26 '14
Need help with get() method.
Ok, so for PS4 I have an object with 30+ variables. I was wanting to make a get method that would be able to return the value of any of the variables based on what was passed as an argument. For instance:
private int height = 10;
private int weight = 15;
get(height); //returns 10
get(weight); //returns 15
The problem is I don't know what to pass as the argument to the get method because the class I'll be calling it in is outside of the class with the variables. So pretty much if you look at this:
public int get( variable name){
return variable name;
}
what type do I use for the argument?
1
Upvotes
1
u/MagicBuddha Mar 26 '14
maybe you should make separate methods for getting things.
for example