Mike Philips

Ranch Hand
+ Follow
since Dec 19, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Mike Philips

Campbell Ritchie wrote:The more you change, particularly if you comment bits out rather than deleting them, the harder the code becomes to read. Also the longer the main method gets. You should avoid long methods.

One of your methods should read a line from a Scanner. I would actually put that in a different class. Have you been told what Scanner#nextLine() does? If yes, were you told correctly? There are even books which give the wrong answer to that question. A few hints about Scanner will be found here and here.



Cheers Campbell - I was uncertain as to whether I should have split this up, it felt a bit stretched out...

Thanks for the link I'll have a look, I've read stuff about the scanner.... Reads the system input? Hopefully that link will iron thing's out a bit
11 years ago

Stuart A. Burkett wrote:What do braces { } do ?



Without a google they contain code.... Anything declared within braces isn't recognisable outside of them...

Oh god I've just slapped my face. Argh I forgot the braces

OK I've amended that a bit now!



I think it works? If there are any faux pas in there then it'd be great to high light them.

I think I'm going to try and generate questions some how rather than them being fixed in the code...
11 years ago
I'm guessing that userAnswerInt = scan.nextInt(); is the incorrect answer to this as it seems like the obvious one, and It's not really changing the value if it just keeps spinning around endlessly. I thought that scanner automatically waited for user input for some reason...

I've changing the value of userAnswerInt within the while loop, but it keeps looping round whether it's the correct answer or the wrong one...

I'm not really sure
11 years ago
Ah I've changed that, I put a dummy String (line 35) in that I remember seeing somewhere (though I'm not too sure why this works exactly) So the scanner reads now... Though I fall into a bit of an infinite loop on the while that follows

11 years ago
Cheers Stuart -


Where are you checking the value returned from the scanner ? Immediately after the call to scan.nextLine or after you have overwritten it on line 27 ?



Ah I mixed up on line 27, it should be userContinue = continueAnswer;

I forgot about the .equals method as well....

I've had a play and I'm getting confused still, line 36 doesn't appear to be letting me input and I'm not sure why
11 years ago
I'm just messing about trying to write little bit's and bobs, and have written this :



All the program is meant to be doing is asking the user a question and then giving an appropriate response, if the user wants to try the question again the program loops around. The scanner in the do while loop isn't actually taking any input though

Any help much appreciated
11 years ago
oh ok
11 years ago
OK great! Yes it was a bit of a spin
11 years ago

Campbell Ritchie wrote:Most of us simply read the Tutorials online, so we never use a downloaded version.



Yup seems to be the case! As do I really... But I thought It'd be nice to have them in case I spill tea on the router or something
11 years ago

Winston Gutkowski wrote:

Mike Philips wrote:I appreciate your views, but you must empathise with mine and see the reasons that I may choose to use one. There is no ultimate 'right' answer here, I agree with the points you make and I understand them, and I'm still using an IDE. Lot's of very reputable courses use IDE's, it's not a crazy concept.


OK, but then you need to take the time to separate what your question actually is from the IDE you're using; otherwise you're asking us to do it for you and plough through a lot of irrelevancies about the IDE.

Java is Java is Java, and you're in a Java forum.

And there's no point in saying that your thread wasn't about IDEs, because as soon as you got your downloads, the next question was "how do I deal with these in Eclipse?".

Winston



Yes I was confused as to the best way to access the downloaded Tutorials, which no-one really answered. The files are like a HTML DB of the tutorials, they aren't just book marks. I didn't twig though as whenever I opened one it came up in the browser so I just thought it was bookmark (I'm guessing this was pretty obvious so people just thought I knew that bit) The question was more how to handle the tutorials.
11 years ago

Winston Gutkowski wrote:

Mike Philips wrote:Yes, I imagine they're great for bad spellers in general... I can barely write English (my native language...) without the aid of a computer. My spelling (and grasp of) is atrocious.


Sounds like a justification for laziness to me.

The fact is that computers in general - not just Java compilers - do exactly what they're told; so if you don't learn to spot mistakes early on (and spelling is big one), you're going to land yourself in deep caca one of these days.

As to the IDE/non-IDE argument: I don't think anyone's saying that you should never use an IDE; just that right now may be a bit too soon. It also means that questions are couched in terms of the IDE you're using, rather than what you're doing; so if we don't happen to have it/use it, we're unlikely to be able to help you.

It's probably also worth mentioning that we have a forum specifically targeted at IDEs (look under "Engineering : IDEs, Version Control and other tools"), so perhaps your question would be better targeted there. If you'd like one of us to move this thread there for you, let us know and we'll be happy to do it.

Winston




The thread was never about IDE's, it just got turned into one (so perhaps it is now?). I appreciate your views, but you must empathise with mine and see the reasons that I may choose to use one. There is no ultimate 'right' answer here, I agree with the points you make and I understand them, and I'm still using an IDE. Lot's of very reputable courses use IDE's, it's not a crazy concept. But I'm just meant to think 'oh well this person on the forum said don't so I can't'. That's not logical is it? I'm listening to your advice, seeing courses that use it, and considering how I personally feel happier operating things.

This doesn't mean I'm ungrateful, or that advising me on Java is a lost cause.

Implications so far have been that I'm lazy, not worth helping and I'm expecting something along the lines of stupid next.

Thanks

11 years ago

Bear Bibeault wrote:Are there formatting options you are looking for that aren't available via the buttons at the top of the posting box?



Yeah, like highlighting [highlight] and putting thing's in boxes [il] and stuff like that....
11 years ago
is there a list of BB code that works on this site anywhere? I tried to use a few thing's to make the post easier to read but it didn't work.

cheers
11 years ago

Campbell Ritchie wrote:The if statement checks one letter only. It is called up to thrice. It checks for letters which are not equal. If you get a non‑matching value, it calls continue on the outer loop.



OK so the program would see L, reference it against subString's s, see that it's not matching, go to the continue, and restart from the for loop, but with i now having a value of 1.

Meaning that when the program looked again it would reference o, check it against the second element of subString, and hit continue again...

Once i got to a value of 11 the program would see s, and instead of hitting continue (because the characters are no equal) the program would (I'm stretching a little here) stay on the while loop, yet the value of n would now be reduced to 2, and 1 added to both j and k.... because the program was now looking at the subString within the searchMe String this would continue, and n would reach the value zero before the if statement would find a non-match.

As the while loop has been "completed" (ended / finished?) the program goes straight to the next line of code out of the scope of the while loop - which sets foundIt to true, and breaks out of test....

Is that right? Or is there something that I'm missing there?

Cheers Campbell.
11 years ago