Campbell Ritchie wrote:I was so intrigued with this that I expanded the appExactly as expected. Please supply more details of your app; I cannot reproduce the problem.
Stuart A. Burkett wrote:Are you sure the itemName variable doesn't include any trailing spaces ? If it was(that's 11 trailing spaces) it would push the value position out.
Try using
to see if that helps.
Campbell Ritchie wrote:No, don't play around with it.Investigate the error properly, by putting proper debugging code in.
Another design error I have seen:- What will happen when your recycling stuff is a "glass bottle"? You have some bad design with those if‑elses. They are using implementation details of the recycled item class, viz that it might be a can or plastic bag. Adding bottles or foil containers means you have to change the code twice. You should only change the code once.
Maybe, move the counting into the item class. Maybe, you don't yet know how to do this.
Campbell Ritchie wrote:What is totalCans? Is it a field? Why? If you run that method twice, are you going to get an incorrect number of cans?
Lee Sigauke wrote:I have also discovered something new, if I print my output on console it works out but on a JTextArea it doesn't print how I want it.
Campbell Ritchie wrote:
You never said anything about text areas. Please read this.Lee Sigauke wrote: . . . but on a JTextArea it doesn't print how I want it.
Tony Docherty wrote:
Lee Sigauke wrote:I have also discovered something new, if I print my output on console it works out but on a JTextArea it doesn't print how I want it.
In that case your JTextArea is probably using a proportional font rather than a mono-spaced font. Try specifying a mono-spaced font.
Campbell Ritchie wrote:Apology accepted.
Lee Sigauke wrote:I had also assumed that...
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|