• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

help with methods return types

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have car class
and a method in that methods I need to return those values,in program that will be calling on that method and it's findingmatchingcar class with it's with 80% or greater of the users required inputs my question is I'm having program with the return types and how would I return those values and have them get printed? thanks Eric
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in that methods I need to return those values,in program that will be calling on that method and it's findingmatchingcar class with it's with 80% or greater of the users required inputs my question is I'm having program with the return types and how would I return those values and have them get printed?
I am eager to help, but what is the question, again?
 
Eric Johns
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My basic question is I have to return make,model,type,price,safetyrating,mpg if that car is with in my users preference but how do you return values with different types, their are strings,int,doubles.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using different types you could always use the wrapper classes and change them about as you feel fit.
for example

this would turn the String "1234" into the int 1234.
the second part would turn the double 25.50 into the String "25.50"
hope this helps.

[ October 19, 2003: Message edited by: chris czinder ]
[ October 19, 2003: Message edited by: chris czinder ]
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My basic question is I have to return make,model,type,price,safetyrating,mpg if that car is with in my users preference but how do you return values with different types, their are strings,int,doubles.
You can always return an object that contains all the needed info.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
since 'findfit' is a bool, make the method type bool but put the
after the

so it would look something like

is this what your trying to do?
then you wouldnt be assigning findFit to anything, you would be using it in an if statement, like
or if all your trying to do is Print the details if it fits, make it like this

Then all you would be doing is displaying the information if it was the right car or else display that its not a match. hope this helps.
[ October 19, 2003: Message edited by: Ray Muntz ]
 
Eric Johns
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, that works thanks alot guys
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic