Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Double Variable Class  RSS feed

 
jonathon greenswick
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you create a variable class to hold double values? My String works as I want it to, but I can't figure out how to instance all the double values.



Also, how do i create a constructor that takes the listofItems String and the (to be created) itemCosts double to initialize the instance variables and also uses get and set methods for each instance?

I know (read: i think) that get and set would be something like:



Many thanks in advance!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code tags didn't really work; did you notice that?

I'm not really sure what you're asking, though.
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

You will need some sort of object to hold the prices, maybe an instance of the Cafe class.
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Your code tags didn't really work; did you notice that?
That's because you wrote them yourself rather than using the Code button.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The original poster's question has been discussed already in his cross-post here: Double Variable Class @ Java-Forums.org

Jonathan, please read this link before cross-posting without notification again: BeForthrightWhenCrossPostingToOtherSites

Thanks for your cooperation and much luck.

/Pete
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pete stein wrote:The original poster's question has been discussed already . . .
Thank you for noticing.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!