What the heck does this mean? [modified]
-
This might just be poor wording on part of the writer, but what does this mean: "Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver has on deposit along with the account holder's first and last names." Is the private instance variable this:
static private object savingsBalance = firstName + " " + lastName + "has $" + amount;
And what does "each object of the class" mean? Isn't every single keyword an object? Edit: He wants me to calculate stuff with savingsBalance but I do not think I am able to do that with an object that includes a string with a word like "has"
modified on Sunday, August 2, 2009 5:44 PM
-
This might just be poor wording on part of the writer, but what does this mean: "Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver has on deposit along with the account holder's first and last names." Is the private instance variable this:
static private object savingsBalance = firstName + " " + lastName + "has $" + amount;
And what does "each object of the class" mean? Isn't every single keyword an object? Edit: He wants me to calculate stuff with savingsBalance but I do not think I am able to do that with an object that includes a string with a word like "has"
modified on Sunday, August 2, 2009 5:44 PM
I think he means "each instance of the class". But that's just a guess. And the fact that he said it was a private instance variable means it is NOT a
static
. -
This might just be poor wording on part of the writer, but what does this mean: "Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver has on deposit along with the account holder's first and last names." Is the private instance variable this:
static private object savingsBalance = firstName + " " + lastName + "has $" + amount;
And what does "each object of the class" mean? Isn't every single keyword an object? Edit: He wants me to calculate stuff with savingsBalance but I do not think I am able to do that with an object that includes a string with a word like "has"
modified on Sunday, August 2, 2009 5:44 PM
Nathan Revka wrote:
He wants me to calculate stuff with savingsBalance but I do not think I am able to do that with an object that includes a string
This makes your teacher a bit dumb, IMO, but you can convert a string into a number using decimal.TryParse, or int.TryParse, depending on what type you want. You can also use the decimal.Parse or even Convert.ToInt32, etc, but the tryparse will not blow up if the string does not contain a number. Of course, if amount is a number, then that's all you would use to calculate with. Storing the savingsBalance as a string, seems odd to me, the balance is the number, the rest is the account name. The string might be rendered by a helper method, but surely amount is also being stored somewhere ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.