NNTP-Posting-Date: Sun, 16 Jun 2013 13:52:09 -0500 Date: Sun, 16 Jun 2013 19:52:08 +0100 From: lipska the kat <"nospam at neversurrender dot co dot uk"> Organization: Trollbusters 3 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: About java program. References: <324f929f-772e-4004-81e1-6b454cdae794@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 47 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-HOnlb+zvdyTpVGKKdx5Pt2tBICGHMFsHHPpGiZ0dSESZcLNNTNmfSfqVvool/Vbv+4FCZoBuw0MnsZ0!ebfHZVRCb8zWEJlS3GemYkSH3Qc42tHq+bt+zRZ1DXmVRNptb3PueH4C9aoG4Lad15QxQyVgtvY= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2801 Path: csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail Xref: csiph.com comp.lang.java.programmer:24427 On 16/06/13 16:28, Robert Klemme wrote: > On 16.06.2013 15:21, lipska the kat wrote: >> On 16/06/13 00:12, Robert Klemme wrote: >>> On 15.06.2013 22:38, rajbhaumik@gmail.com wrote: >>>> import acm.program.*; >>>> public class askYesNoQuestion extends ConsoleProgram { >>>> public void run(){ >>>> String str=readLine("Would you like instructions"); >>>> println(askYesNoquestion(str)); >>>> } >>>> 7. private boolean askYesNoquestion (String str){ >>>> if(str.equals("yes"))return true; >>>> if(str.equals("no")) return false; >>>> } >>>> >>>> } >>>> the false is that , the program cannot be executed, because no 7 >>>> said, this method must return a type of boolean. >>> >> >> One possible solution (not compiled or tested) >> >> private boolean askYesNoquestion (String str){ >> boolean response = false; >> if(str.equals("yes")){ >> response = true; >> } >> return response; >> } > > Why are you making it so complicated? Just do > > private static boolean isStringYes(String str) { > return str.equals("yes"); > } This is the age old argument about the use and abuse of the return statement. I can't see us coming to a MAC so there's little point arguing about it here really. But OK, it's another solution. lipska -- Lipska the KatŠ: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun