Win a copy of Securing DevOps this week in the Security forum!

Nigel Browne

Ranch Hand
+ Follow
since May 15, 2001
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 Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nigel Browne

The only one I know of is called 'How to program with Java Podcast', you'll find it here
8 months ago
Your newOwner class can not access the methods in class Owner. You neeed to instantiate an instance of class owner and then call the methods on the class instance.
2 years ago
You getter methods shouldn't have an argument
2 years ago

Paul Clapham wrote:I have no idea how to tell Eclipse to redirect to use a particular file (even though I've been using Eclipse for years now). But you could change the program to read from the file directly instead of -- that's what I would have done in the first place unless I was sure the people I was teaching had already had some training in using the command line.

Probably a bit advanced for this forum but this one way how to redirect from eclipse:

Create an Ant target and launch it as "Run External" from Eclipse, here are the steps:

I have one input file to read from: res\in.txt and one for the output: res\out.txt
Create a build.xml with the targets you require (this is just an example):

In Eclipse go to: Run->External Tools->External Tools Configurations->Ant Build-> New Launch Configuration use the following configuration:

Section Main

Buildfile: ${workspace_loc:/Tests/build.xml}

Base Directory: ${workspace_loc:/Tests}

*Note: Tests is the name of my Eclipse project

Now you can run your project by clicking in the Run Extenal tool bar button and change the input or output files as you needed

Also if you are using Eclipse version 4.5 or higher
Run Configuration -> Common -> tick Allocate console (necessary for input), tick input file. In the textfield enter full path address to input file.
2 years ago
Question 4 states which option, which I take to mean that only one answer is correct, however both a and d will print 10 to the command line
I'm not sure what your program is supposed to do, but you have set the variable c to null and that is why you are getting a null pointer exception.
2 years ago
A few comments on your code.
line 30 retValue = f; you haven't declared a variable retValue
line 18 this should actually be your pivot

This eleminates your first swap and increment of f
In your second while loop condition you check that f < l, you already know this is the case as that is the condition for your first while loop. Then in your third while loop you check for less than or equal to, this would be better as the condition to the first while loop.

In your second code block line 2 MIN is never used.

Why did you create a sort method that just calls the qSort method? You know the name array you are passing to qSort in your main method of Q_Sort therefore you could call qSort directly from there.
2 years ago

This breaks down as follows:
^ //start of the line
[_A-Za-z0-9-\\+]+ // must start with string in the bracket [ ], must contain one or more character(+)
( // start of group #1
\\.[_A-Za-z0-9-]+ // follow by a dot "." and string in the bracket [ ], must contain one or more character(+)
)* // end of group #1, this group is optional (*)
@ // must contain an "@" symbol
[A-Za-z0-9-]+ // followed by a string in the bracket [ ], must contain one or more character (+)
( // start of group #2 - first level TLD checking
\\.[A-Za-z0-9]+ // follow by a dot "." and string in the bracket [ ], must contain one or more character(+)
)* // end of group #2, this group is optional (*)
( // start of group #3 - second level TLD checking
\\.[A-Za-z]{2,} // followed by a dot "." and string in the bracket [ ], with minimum length of 2
) // end of group #3
$ // end of the line
2 years ago

Junilu Lacar wrote:

phi tran wrote:Mis-spelled is misspelled XD.


Misspelled is misspelt in the British isles
2 years ago

Stephan van Hulst wrote:I don't think the CardLayout is appropriate in this case. CardLayouts are for different layouts in the same component. This is the same layout, but different data.

That depends on the questions on the the cards. Some might be multiple choice with only one correct answer using radio buttons, others maybe multiple choice with more than one answer that is correct using check boxes.

Layout tutorial
2 years ago
First I suggest you read the Swing or JavaFX tutorial. Next look up the LayoutManager interface and the CardLayout class in the java api.
2 years ago
The original question has already been answered by other posters, however you have numerous issues in the code you have written so far. If you had broken the project down into smaller tasks and then tested along the way, then you would of already found them by now.
For example your method to calculate the rental cost doesn't take in any arguments so how does it know which customer and auto it is calculating the cost for ?
Your COST_PER_DAY constant should be static and then you dont need a getCOST_PER_DAY method
Your test for day discount starts at 7 days and not 6
There are more issues but I'll let you re-evaluate your code before point out anything else.

Keep on asking questions and posting your work and you'll get the help needed.
2 years ago

sampada shukla wrote:

why the output is false true.when in both string and Integer comparison we are comparing object reference to the value?

It isn't the output is false.
The first if statement makes the comparison between the String literal "Hello" and the Sting Object t, which are not the same.
The second if statement compares an Integer object with an int primative, which are not the same and due to being false doesn't print anything.
If you wish to assert that the value of String object t equals hello use the following
2 years ago
You might be interested in reading this thread Main Pain
2 years ago

Craig Cantell wrote:

Junilu Lacar wrote:Welcome to the Ranch!

We encourage students to do their own homework. If you're working in Eclipse, why don't you just run the program and see for yourself?

I want to independently do my homework but I don't understand how to evaluate it mentally or by hand, we have tests and we cannot run the text through the program. I just need someone to explain the process to me please.

You are correct that the code you posted will not run if copied directly into Eclipse, however you can create a simple test class and paste the code into the main method and run it.

2 years ago