Campbell Ritchie

+ Follow
since Oct 13, 2005
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 Campbell Ritchie

Congratulations all four of you

And one winner is called Campbell
4 hours ago
Welcome to the Ranch again.

FX is good, but it is not intended to replace applets; in fact there is nothing intended to replace applets at present.
4 hours ago
. . . and Welcome to the Ranch

Have you worked out what DD meant about line 10?
4 hours ago
If you have multiple concatenations in the same statement, us + throughout.
If you use + or += repeatedly in a loop or similar, use a StringBuilder.
That sounds just like what Carey told you.
4 hours ago

onagh grange wrote:. . . Thanks again

That's a pleasure but please show us the code with the Comparator. Also show us how you are initialising the ID numbers in the rental objects.
22 hours ago

onagh grange wrote:. . . iterate through the loop using a comparator . . . .

What Comparator? That is the first you have said about Comparators and there aren't any Comparators in the code you have shown so far. You don't use Comparators for iterating loops, but for working out whether object1 should be sorted before object2 or not. What you were doing last night was to test whether your ID was the same as one of the videos' IDs. I thought you had got that part to work. You can read about Comparators etc. in the Java™ Tutorials,, but you might not have the time to read that section just at the moment.

Daniel Demesmaecker has given you a good hint, but I can see problems with that approach:-
  • 1: What if there are two different rental objects in the List with the same ID? I think you should be able to ensure that doesn't happen.
  • 2: What if the same object with the right ID appears twice in the same List?
  • There are ways of coming out of the loop when you find the right ID.
    22 hours ago

    Junilu Lacar wrote:. . .

    That is the sort of thing I meant. You can shorten it to:-But maybe Junilu's version is easier to read.
    22 hours ago

    Carlota Vina wrote:Due to the method play() of Game throws a Exception, the main must to handle this exception(with a try-catch or with throws)

    No, it doesn't throw an exception; it declares it. If you have a plain simple Game object, then you must handle the exception. Come to thin kof it, you are correct; because your references are declared as Game, you must still handle the exception because the compiler cannot know whether a subclass does or doesn't declare Exception.
    I had forgotten that you are declaring your objects as Game: sorry.

    Liutauras Vilda wrote:. . .  it was raining so much that I couldn't remember anything similar

    That was nothing compared to the time my daughter and I were cycling through Colchester; it started raining when we got to Westway, along Cymbeline Way, the old A12 bypass. By the time we got to North Station Road, another ¼ miles, the water was 2″ deep on the streets, and then it got really wet. By the time we got to the University of Essex about two miles further, the roads were dry and there was a blue sky.
    Or the Sunday in August 2003 when we had rain running down the Church walls, on the inside, and A*** S***** left her sunroof open in her car and found a couple of inches of water inside the car.

    . . . To my surprise he was completely dry . . ..

    I managed to get to the station and under cover before the rain started.
    1 day ago
    What does that code do? You are using the font metrics object to calculate the location. So you are simply writing your format String and not passing the lives local variable to anything to print out. Find out about Formatter, and the other methods using Formatters, vizthis, this, this, and this, along with their overloadings. I think you will find the second “this” will do what you want, but they are all related. More information in the Java™ Tutorials: link 1 and link 2.
    1 day ago
    Last night, I used %PATH% as an abbreviation of the PATH as it stood before. I have just realised that might be confusing; you end up with a PATH starting JAVA_HOME... and then followed by all the other elements.
    1 day ago
    By the way, if yoiu follow the Java™ Tutorials link I gave you last night, does it tell you to add the new PATH element at thee end; that isn't actually correct. You are usually better off adding the new PATH to Java® to the beginning of the PATH.
    1 day ago

    Carlota Vina wrote:Then the order it b.getH() and after the System.out.println?

    That doesn't look clear, but I think the answer is no.
    You go from left to right. The order is therefore,
  • 1: Find system class
  • 2: Find its out field
  • 3: Find its println() method, but that cannot complete until it “knows” what its argument is.
  • 4: Evaluate the argument for println(), inside the (), starting with "Beta "
  • 5: Then execute the + operation
  • 6: The + operator finds it is necessary to run the getH() method first. I shall abbreviate getH() to one line and forget that it includes a print instruction. When getH() returns, the + operator can complete its task.
  • 7: Now that the argument for println() is complete, the println() method can complete its execution
  • At least I think that is right.
    Welcome to the Ranch

    Please start by explaining what the app should do.
    1 day ago
    Welcome to the Ranch

    I think you will have to decide for yourself whether you prefer a video over a book; both have their advantages.
    I haven't used videos myself, but most people speak very well of Udemy. Consider exploring the Packt website because they have a special offer coming up on Monday. Several publishers make different products available at a discount, e.g. Manning.