Joseph Sillitoe

Greenhorn
+ Follow
since Dec 30, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Joseph Sillitoe

So is that June 9th or September 6th?

Either way, why don't you just take a stab at it and post what you've come up with? That would make it so much easier to help you.
12 years ago
You don't need the quotes at all.

just try:



Unless, of course, the quote is part of the pattern that you are checking against. In that case, I think you would need to escape them with a \ like this:

12 years ago
Mark,

Why don't you post the code that you have. Then we can all take a look and see if we can be helpful.
12 years ago

Well, if we get rid of the space at the end of "Honey ", and use an Integer or Long rather than a Double, then we could parse it as a number in base 35 or higher...



pffft. Only if we assume that it is not case sensitive. Otherwise we obviously cannot parse this in any number system less than base 61.
12 years ago
Good Job! You are almost there.

A couple of things that I would like to point out:

You have this:


And then later, this:





Both of these loops do the exact same thing (iterate through the loop exactly x number of times), so maybe we can abstract that out into a method?
(Also, please note that it is considered good practice to start counting from zero, like you do in the first one.)




But wait... we need to be able to print other characters besides a star. Lets refactor this to:




Now to use that method in your code. All you would have to do is:




Now all we have to do is get those pesky space chars printed ahead of our stars.
[ January 05, 2006: Message edited by: Joseph Sillitoe ]
12 years ago
Please don't get defensive. Satou is absolutly correct in the advice he gave you. Indeed, if you abandon the whole "if (x==2)" thought process and started rethinking the problem in the ways that Satou, Adam, and I are hinting at, the "space" part of the problem will almost solve itself.

Maybe it would be helpful to understand if instead of the diamond filled with *'s and spaces, you did something like this:




or even better:

12 years ago
Acctually,

1) Yes, kind of. Suppose you have two properties files in the "resources" directory (which also is in the classpath). The names of the files could be:
  • propfile1.properties
  • propfile2.properties


  • The contents of the "propfile1.properties" file could include:



    Then it would be a matter of loading the first properties file, extracting the name of the second one, and then loading that one as well.




    12 years ago
    From the OP link....



    60 // This is the second break down
    61
    62
    63 int n = 4;
    64 for (int x = 1; x < n; x++) // the x(2) was incrimented by 1 from the first break down
    65 // since of the x++
    66 {
    67 System.out.println(); // makes it on a new line
    68
    69 for (int y= 1; y < 2; y++) // the x gets changed to 2, now how does this work?
    70 // it makes sence if 1 since that seems to get the desired result
    71 // but thanks to the y-- one we had a zero when we left
    72 // and since the int y = 1 was intillized already with the
    73 // first time around it does not run anymore otherwise that would
    74 // screw things even more up.
    75 // so if it is zero that will work since zero is less then 2
    76 // but that will not get use the desired result.


    77
    78 {
    79 System.out.print(" "+ y);
    80 }
    81
    82 for (int y = x; y > 0; y--)
    83
    84
    85 {
    86 System.out.print(" " + y);
    87
    88 }
    89 }



    For the comment starting on line 69, The reason this works is because 'y' is reinitialized to equal '1' every time we enter that for loop. I assure you that the code does indeed work and get the result that we are looking for. The more I think about it, I think that you might be getting confused on the scope of the x and y variables. The code could be re-writen like this and still do the exact same thing:







    12 years ago
    Michael,

    I am happy to hear that you are trying to fully understand the nuances of code that I posted about the loops. Here is a commented version for you to look at. I hope this helps!



    12 years ago
    Ok, Here is another way to do this... using the % operator and a little help from our friend "Math.min()". It still uses loops but not in the way you might think.




    I hope this helps
    12 years ago
    Ok, I think that the semester is prolly over so I think its safe to post an answer to this...

    As noted before, this looks like a homework assignment to practice loops. So here is my really loopy answer:



    I'm also working on a slightly more convoluted way using the % operator... stay tuned.
    12 years ago
    There is acctually a pretty good
    article about this topic on this site:

    http://www.javaranch.com/campfire/StoryPassBy.jsp

    To demonstrate what the Ilja and others are saying, here is an example using a mutable object (StringBuffer).




    The output of the this code will look like:



    Cheers.
    12 years ago