charlie swift

Ranch Hand
+ Follow
since Oct 28, 2017
charlie likes ...
IntelliJ IDE Oracle Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
45
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt Green check

Recent posts by charlie swift



Campbell Ritchie wrote:Because in the past we had frequent problems with people “correcting” mistakes in old posts, so the replies looked like nonsense. Shall I correct the code tags for you?
Don't use <> for code tags: it's [], but the button is quicker. The HTML <code> tag changes the font and I have only seen it used in javadoc comments.



Thanks for clarifying. The reason for for not having an edit button makes sense. Yes, please correct the code tag. And I usually use the buttons for adding tags but this time i was using 'quick reply' box which has not buttons. But I'll keep in mind to use square brackets [] in the future.
6 years ago
6 years ago
Thanks so much for the advice. After getting rid of all those redundant check/variables, the code got much easier to read.

Carey Brown wrote:On line 26 you are testing numberOfSixes!=3, you've already done that test on line 23. If you clean this up on line 26 then line  28 should become a simple 'else'.

The use of your boolean 'NotThreeSixes' is redundant, you can just test numberOfSixes!=3.

6 years ago
Thanks I'll look up java streams; it sure seems like an easy way of programming the same thing and like you say "saves ... all the bookkeeping" (great phrase by the way)

Piet Souris wrote:Another way, that saves you from all the bookkeeping and brings you into the realm of java 8 streams...

Suppose you have the integer sequence 1, 2, 3, .... Now, keep only those integers for which the roll of the die equals the number-to-be-rolled (call that number S), and from this reduced sequence take the first N numbers, where N is the number of times we must roll S. The last number of that reduced sequence is the required number of rolls. It should just take a few lines.

6 years ago
Thanks for the brilliant advice

I took your advice and implemented it and here's the new code. Is it better now? Any other suggestion that I implement to improve the code?



Knute Snortum wrote:One way you might think about getting rid of the inner loop is creating a variable something like "the number of times I have already seen a six."

There are many other minor improvements that you do to your program:

* Get the code out of main(), see MainIsAPain (that's a link).

* Only declare variables right where you need them.

* The Random object should be declared only once.

* Remove comments that just say what the code says (most of your comments)

* Use more descriptive variable names (ns -> numberOfSixes)

6 years ago
Hi

I wrote a program to simulate a die. The program counts how many times the die needs to be rolled to obtain 3 consecutive sixes. However it's pretty long and contains nested loops and many variables. Is there any simpler way to achieve my objective? How might I make this code more simple so that it's easy to understand (in it's current form it's difficult to follow the flow of commands    )


Here's my code:

6 years ago
Hi,
I complete OCAJP SE 8 last month. I now wish to pursue OCPJP. My question is: Would it be better to wait for OCPJP 9 or should one just get certified with the current version 8?
Thanks,
cs

Daniele Barell wrote:Great score Charlie! Congratulations!



Thanks I wish you good luck with your preparation for OCA exam.
6 years ago

Liutauras Vilda wrote:Did you take test in Java or Swift? Just joking, congratulations, very well done


Thank you. I sure did take Java's test cause it goes well with coffee. And who can resist coffee, right? ( )
6 years ago

Ganesh Patekar wrote:Don't forget to add your name to OCAJP Wall of Fame



Thanks I've not as of yet added my name their but I'll do that now.
6 years ago
Corrected one or two mistakes in the post:

charlie swift wrote:Hi,

Yesterday on 22 January I took the OCAJP SE 8 test and passed with 94%. I'm really grateful to Jeanne Boyarsky and Scott Selikoff for writing such an amazing book for preparation of OCAJP. Hats off! Also, the Enthuware exam simulator is a really good one for practice tests but I found that it had comparatively more difficult questions than the real exam (but as they say you can never over prepare, right? )

Apart from that I did all the questions and the practice test from Java OCA programmer practice test book by Jeanne & Scott which really did prepare me to handle awkward looking syntax and recognise all those nuances which might result in a compile time error or a runtime exception.

Thank you all here at CodeRanch for clarifying and explaining the stuff that was confusing. You guys are really great!

CS

6 years ago
Hi,

Yesterday on 22 January I took the OCAJP SE 8 tests and passed with 94%. I'm really grateful to Jeanne Boyarsky and Scott Selikoff for writing such an amazing book for preparation of OCAJP. Hats off! Also, the Enthuware exam simulator is a really good one for practice tests but I found that it comparatively more difficult questions than the real exam (but as they say you can never over prepare, right? )
Apart from that I did all the questions and the practice test from Java OCA programmer practice test book by Jeanne & Scott which really did prepare me to handle awkward looking syntax and recognise all those nuances which might result in a compile time error or a runtime exception.

Thank you all here at CodeRanch for clarifying and explaining the stuff that was confusing. You guys are really great!

CS
6 years ago
Are we asked question regarding the use of java.time.temporal.TemporalAdjusters in the OCAJP 8 exam?
I wasn't able to find it in OCA Sybex guide (Jeanne & Scott) but Enthuware had a question regarding the use of TemporalAdjusters

Are we supposed to know about the getClass().isArray() method of the Object class for the OCAJP 8 exam?

From Enthuware Practice Test 4: Question 4


Enthuware explanation for this question says "There are a few questions in the exam that require you to know about this."