Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using a getter to retrieve different parameters

 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating a program where I need to pass different parameters into a single getter and have it print out different valaues based on the paramter.

So far I have one string which I used substrings to divide the string into different chunks then convert them to ints. so now I need to assign these different ints to paramter numbers which would be passed through to the getter for printing.




this is how the different values would be passed into the getter:



Any suggestions on how I could accomplish this?

Thanks a lot for the help
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben Hultin wrote:


i Assume IpAddress is a Constructor .

there are 2 ways to accomplish this task.
one way is provide getter/setter for octet1,octet2,octet3,octet4 . an another way is wrap the values into a single int Array and provide getter/setter .

Hope this helps
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, if you're passing a parameter into a "getter", then by definition, it isn't a "getter".

(Unless you start contemplating indexed properties -- but there are strict rules that must be followed there as well.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic