Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
Win a copy of Spring in Action (5th edition) this week in the Spring forum!

salvin francis

+ Follow
since Jan 12, 2009
salvin likes ...
Eclipse IDE Google Web Toolkit Java
Forum Moderator
salvin francis currently moderates these forums:
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by salvin francis

Daniel Demesmaecker wrote:Lol, I agree, but I'm carefull now a days with writting to mutch code to help someone out especially in the beginning java forum.

I am pretty sure the staff meant that you should not share a full baked solution. There are rules for that here.

orlagh green wrote:unfortunately it did not work for me. It did not retrieve the right object via the id number

That is unfortunate, can you share the searchGameById method implementation where you pass an id and it retrieves the wrong object ?
2 hours ago

Daniel Demesmaecker wrote:As I alrady pointed out, there a lot of ways this code could be simplified,

Agreed, I am trying to push OP in the right direction too

Daniel Demesmaecker wrote: the objective was to make it run first...

This is a matter of preference, some problems need a nudge in the right direction and some problems need to solved first and then optimized. In this example I feel that separating intent of the method into smaller manageable method calls with clear intent may help OP solve the problem better.
2 hours ago
I feel that your make rental code should be something like this :

searchGameById should do the job of searching and returning. Your current code of looping through all rentals is not right.
3 hours ago
I have a few review comments :
1. IsEven check :

Can you make it simple like this :

2. Next, initNums(int n) is a bad name for a method that initializes an array of n random numbers. Can you come up with a different name e.g.: generateRandomNumbers(int arraySize)

3. Next :
Usually we run a for loop on an array like this:
The advantage over your code is that every time your loop completes it does not need to add 1 every time it needs to do a boundary check.

Think of your code as a story and your method names are actions in your story. "Driver" does not tell me anything about your code. "bar1", "P", "rando", "n", "nOverP" are all bad names for instance variables. Think about anyone maintaining your code. fillPool() does not live up to its name, it also does more things.
6 hours ago
I am surprised to see this level of complex code being taught in schools. What exactly is not working in your code ? and why are you implementing the sort algorithm instead of using Collections.sort() ?
1 day ago

Irene Song wrote:Hi, I'm a beginner at programming and I don't understand how I can check if the user's answer is correct. Am I doing this right? ...

  • Does the code run fine or do you see any errors on screen ?
  • I see that you have defined a huge number of instance variables which are not needed (e.g. JPanels)
  • I also see a lot of code duplication here

  • 1 day ago
    I suggest leaving the code aside for now and try this out on a piece of paper.
    Let's say the product price is $200
    and the discount is 10%
    Ignoring the sales tax, what should be the price after discount and how did you calculate that ?

    As campbell pointed out, if we use your formula: 200*(10/100) it equals $20  
    1 day ago
    Here's my thoughts,

    While I totally agree with Campbell about "If it ain't broke, don't fix it." and this is pretty much my approach too. But off-lately, I have a slightly different mindset.

    Does the application have a very thorough and working functional test plan in place that covers all usecases ?

    If yes, then the whole app codebase is your playground do as much as refactoring as you wish since you are able test your changes.
    If no, then you will have to take that step first and write test cases first for all the code that might be affected by your refactoring so that you know that it works before and after your refactoring.
    6 days ago
    I am a gamer. I have unlimited re-spawns (lives)
    6 days ago

    Junilu Lacar wrote:...

    Agreed !

    Although I suggested it, I dislike "meetsFalseRequirements". I am having a hard time thinking of a method that succeeds and yet returns false
    6 days ago

    Junilu Lacar wrote:...

    Is incorrect, but you have proved my point.. two negatives in sentence confuse us all.

    Problem statement:
    Given an array of ints, print 'false' if the value '3' appears in the array exactly 3 times and no '3's are next to each other. Otherwise print 'true'.

    Maybe if you called your methods : hasAnyConsecutive3s and meetsFalseRequirements I would agree with you

    Also your check would be:
    6 days ago
    I suggest compareToIgnoreCase() method instead of converting the strings to lower case.
    1 week ago

    colten Short wrote:so what would I add to the original code to make it loop?

    You need to understand the do-while loop first. Did you understand how your while loop prints "Hi" 10 times ?
    As per java tutorials:

    java tutorials wrote:The while statement continually executes a block of statements while a particular condition is true

    Similarly the do-while loop has the feature that the block is executed at least once (the first time) and then the condition is checked. Here's a simple code:
    1 week ago