Brown_Man
New Member
Calculus make Brown Man mad!
Posts: 3
|
L8
Nov 4, 2001 20:13:18 GMT -5
Post by Brown_Man on Nov 4, 2001 20:13:18 GMT -5
Thanks. I thought that we had to create a new GroceryItem object everytime the user enters a new item.
|
|
|
L8
Nov 4, 2001 21:28:54 GMT -5
Post by Brutal_Chicken on Nov 4, 2001 21:28:54 GMT -5
Whoa, run that by again? We do have to create a new groceryitem with the new input until the user types "quit". All the values entered are placed into static methods and are cumulative.
Oh yeah, thanks Blues but will a boolean or an int store "quit"?Won't it be thrown out? Guess I'll find out.
|
|
|
L8
Nov 4, 2001 21:46:17 GMT -5
Post by Majin_Blues on Nov 4, 2001 21:46:17 GMT -5
um, i think so... so it should be part of your loop - remember, you only need to input parameters for grocery item, then there's a method that'll sum up for you
and they don't. you store the input as string first, then convert it to whatever you need to (i.e. when user enters taxability, quantity, etc. - save input as string first, check if it's "quit" - if not, convert it)
|
|
|
L8
Nov 4, 2001 22:09:10 GMT -5
Post by Sky on Nov 4, 2001 22:09:10 GMT -5
What? aren't we are suppose to instaniate a GroceryItem everytime when there is new input that is not "quit"...it said that on the handout...
|
|
|
L8
Nov 4, 2001 22:35:55 GMT -5
Post by Majin_Blues on Nov 4, 2001 22:35:55 GMT -5
What? aren't we are suppose to instaniate a GroceryItem everytime when there is new input that is not "quit"...it said that on the handout... you're right... it's part of your loop... the parameters part was only because he was asking about static variables and stuff(sorry if i misled anyone)
|
|
|
L8
Nov 5, 2001 7:04:40 GMT -5
Post by Brutal_Chicken on Nov 5, 2001 7:04:40 GMT -5
and they don't. you store the input as string first, then convert it to whatever you need to (i.e. when user enters taxability, quantity, etc. - save input as string first, check if it's "quit" - if not, convert it) I see where you're going. Just use the plain old input readLine then check if it's "quit" first then convert it to what's needed. Great idea. ;D
|
|
Sean
Full Member
Posts: 36
|
L8
Nov 5, 2001 10:39:24 GMT -5
Post by Sean on Nov 5, 2001 10:39:24 GMT -5
In the CSC108 newsgroup, a TA/teacher mentioned the user would only type 'quit' at the start of each cycle, ie..name of item. If he didn't type it at the start, you could assume the user would input the price, tax, etc. I'll find the quote when I get home. Of course your method will still work, but it might be unnecessary.
|
|
Sean
Full Member
Posts: 36
|
L8
Nov 5, 2001 10:46:57 GMT -5
Post by Sean on Nov 5, 2001 10:46:57 GMT -5
|
|
|
L8
Nov 5, 2001 14:14:20 GMT -5
Post by Majin_Blues on Nov 5, 2001 14:14:20 GMT -5
> Does it mean that he will not enter a name and then try to enter quit > instead of a price, or he will not enter a name and then a price and > then enter quit? Correct. i already read it at the newsgroup but this was the part that was vague - i mean, there's two questions and all the guy says is "correct" to what? GEEZ... darn replier... so better safe than sorry...
|
|
|
L8
Nov 5, 2001 15:48:47 GMT -5
Post by Newtype on Nov 5, 2001 15:48:47 GMT -5
When they ask if an item is taxable, shouldn't the item have no taxvalue if the boolean is false ? For example: Orange [Enter] 6 [Enter] false [Enter] 1 [Enter] Purchases:17.0 Tax:1.65 Grand Total:18.65 Since we put isTaxable as false, there should be no tax right? Shouldn't the total is just $17.00? But this isn't our fault though, cause I looked at the GroceryItem.java and they put: if (isTaxable) { <--- shouldn't this be (isTaxable == true???) totalTax += price*n*TAX_RATE; } oh well...
|
|
|
L8
Nov 5, 2001 16:05:28 GMT -5
Post by Brutal_Chicken on Nov 5, 2001 16:05:28 GMT -5
Since the first item was taxable it's taxes still apply and the total is cumulative so that's why you get that total.
And dangit all! I just finished modifying my damned L8 and this is what I read. I'd blame Blues ;D but we all know who's really to blame...
|
|
|
L8
Nov 5, 2001 16:07:18 GMT -5
Post by Majin_Blues on Nov 5, 2001 16:07:18 GMT -5
it seems to work for me... did you convert it to a boolean? (see the assignment help on how to do it)
if that doesn't work, maybe you have it set to true somewhere inside the loop or something...
|
|
|
L8
Nov 7, 2001 20:07:45 GMT -5
Post by Sky on Nov 7, 2001 20:07:45 GMT -5
One question...the newsgroup didn't make it clear to me...for L8 if the user input quit in the first line...should we still output the summary...since if there is no parameter we can't instantiate an object and use the getSalesInformation method(but we can always make the values zero create an object to print out the summary, rite?)...also in the handout it said 1. read a value... 2.instantiate a GroceryItem so if not all values are there...we just print nothing?
|
|
|
L8
Nov 7, 2001 20:23:16 GMT -5
Post by bladehunter on Nov 7, 2001 20:23:16 GMT -5
Remember....
The method, getSalesInformation, and the encapsulated data (instance variables) totalPurchases and totalTax are STATIC. If u call the method getSalesInformation if the user types "quit" at the start, it works, since totalPurchases and totalTax are set to 0 (they are part of the class, not the object of the class)
|
|
|
L8
Nov 7, 2001 20:56:29 GMT -5
Post by Majin_Blues on Nov 7, 2001 20:56:29 GMT -5
And dangit all! I just finished modifying my damned L8 and this is what I read. I'd blame Blues ;D but we all know who's really to blame... yes, i understand your point all too well... sorry! all that work for nothing... but at least it gives you practice in being creative for that upcoming test! ;D (but yes... it still sucks)
|
|