Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: bilsch Newsgroups: comp.lang.java.programmer Subject: Re: I need a different approach - suggestions please Date: Tue, 26 Jun 2012 13:04:50 -0700 Organization: A noiseless patient Spider Lines: 44 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 26 Jun 2012 20:04:51 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="VpQo9AeuZ2WQvbzkl6vgHQ"; logging-data="18716"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dXpt1Tt0AnJRss2uk/q5I" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 In-Reply-To: Cancel-Lock: sha1:TYqZtfOkiWujC1aA+8TXjjjinP0= Xref: csiph.com comp.lang.java.programmer:15606 On 6/25/2012 6:10 PM, markspace wrote: > On 6/25/2012 4:47 PM, bilsch wrote: > >> Thanks for the help. I could swear I tried that first but got error >> messages about static and non-static conflict problem. i will be taking >> Java in fall quarter. Right now I'm working from "Learn Java in 24 >> Hours" I thought up the calculator project myself. Thanks again. > > > It was the Q1 parts of your code that really tipped me off. I suppose > you could be planning on a future Q1 class, but it did make it look like > you where taking a course over the summer. > > BTW, another way to improve you code is to watch the big cascades of > if-else statements. For example this: > > if (btn == ".") {strng1 += btn;} > else if (btn == "0") {strng1 += btn;} > else if (btn == "1") {strng1 += btn;} > else if (btn == "2") {strng1 += btn;} > else if (btn == "3") {strng1 += btn;} > else if (btn == "4") {strng1 += btn;} > else if (btn == "5") {strng1 += btn;} > else if (btn == "6") {strng1 += btn;} > else if (btn == "7") {strng1 += btn;} > else if (btn == "8") {strng1 += btn;} > else if (btn == "9") {strng1 += btn;} > > could all just be > > strng1 += btn; > > because you don't do anything different for the different cases. > Copy-paste statement like this should be avoid, because it creates > relatively low value redundancy. Try to combine common cases into one > block. It's easier to go back and modify later. > > > Now that you mention it I see how that would work. However the actual program has many non-numeric buttons I don't want in the string - I better leave that alone for the present. Thanks. Bill S.