Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #16  
Old January 30th, 2013, 03:04 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,956 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 56 m 11 sec
Reputation Power: 345
What is the use of the toString variable? Why is it in the program?

What do you expect this statement to do:
Code:
toString = toString;

The variable on the left side is the same one that is on the right side of the =.
What that will do is take the value of toString and put it back into toString.
That doesn't change anything.

Reply With Quote
  #17  
Old January 30th, 2013, 03:15 PM
jworkman5985 jworkman5985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 12 jworkman5985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 39 m 38 sec
Reputation Power: 0
Quote:
Originally Posted by NormR
What is the use of the toString variable? Why is it in the program?

What do you expect this statement to do:
Code:
toString = toString;

The variable on the left side is the same one that is on the right side of the =.
What that will do is take the value of toString and put it back into toString.
That doesn't change anything.


If Im understanding correctly its supposed to relay the value of price*unitsOnHand to the message in the main method.

My teacher didn't really cover it in very much detail.

Reply With Quote
  #18  
Old January 30th, 2013, 03:25 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,956 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 56 m 11 sec
Reputation Power: 345
Quote:
its supposed to relay the value of price*unitsOnHand to the message

What is the "its"? There are two different things we are talking about: the variable: toStriing and the method: toString(). Which one is the "its" you are refering to? It's important to use proper terms and descriptions when talking about programs to avoid confusion.
You've said that you know the difference between a method and a variable.

Did you see this?
What do you expect this statement to do:
Code:
toString = toString;

The variable on the left side is the same one that is on the right side of the =.
What that will do is take the value of toString and put it back into toString.
That code doesn't change anything.

Reply With Quote
  #19  
Old January 30th, 2013, 03:30 PM
jworkman5985 jworkman5985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 12 jworkman5985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 39 m 38 sec
Reputation Power: 0
Quote:
Originally Posted by jworkman5985
If Im understanding correctly its supposed to relay the value of price*unitsOnHand to the message in the main method.

My teacher didn't really cover it in very much detail.


I think I'm understanding now. I am talking about the method. So the reason its not returning a value is that I am missing the parenthesis?

Code:

	message = String.format( "Jacket \t $", jacket.toString ());

Reply With Quote
  #20  
Old January 30th, 2013, 03:39 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,956 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 56 m 11 sec
Reputation Power: 345
Ok, that's good; get rid of the toString variable and use the method; with the ()s

Now what value is the toString() method returning? To see what values it has to work with, add a call to the println method in the toString() method before the return statement that prints out the values of the two variables that are used to compute the value that is returned. Seeing their values could help you see what the code is doing.
Code:
System.out.println(<PUT THE VARIABLES HERE WITH +" " + BETWEEN THEM);

Last edited by NormR : January 30th, 2013 at 03:43 PM.

Reply With Quote
  #21  
Old January 30th, 2013, 03:45 PM
jworkman5985 jworkman5985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 12 jworkman5985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 39 m 38 sec
Reputation Power: 0
Quote:
Originally Posted by NormR
Ok, that's good; get rid of the toString variable and use the method; with the ()s

Now what value is the toString() method returning? To see what values it has to work with, add a call to the println method in the toString() method before the return statement that prints out the values of the two variables that are used to compute the value that is returned. Seeing their values could help you see what the code is doing.
Code:
System.out.println(<PUT THE VARIABLES HERE WITH +" " + BETWEEN THEM);


Thanks for the advice and all of your help. I won't be able to compile until I get home (Im at work until 8p) but I will try this and let you know.

Sorry for being such a noob and thank you for your patience!

Reply With Quote
  #22  
Old January 30th, 2013, 03:47 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,956 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 56 m 11 sec
Reputation Power: 345
See you later then.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Need help with a class that can be called to do math

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap