It has to be inside the class. Just declare it after main(). It should return a String.
public static String getCityName() {
after you get a value from the user, return that value;
It has to be inside the class. Just declare it after main(). It should return a String.
public static String getCityName() {
after you get a value from the user, return that value;
How would I do that?
Well, move it outside main(). Cut-paste the entire thing outside of the braces that delimit the main() method.
No, you don't put javadoc comments inside methods.
Edit: On an unrelated note, "Number" would be a really bad name for a boolean variable. Number is the base class for numeric wrapper classes like Integer. Variables should also begin with a lowercase letter. "isNumber" would be a better choice and would convey the boolean nature by it's name.
Don't put it in a separate class. It doesn't really have any context as a separate object.
Just make a method getCityName() that returns the String that the user entered.
You can't declare methods inside other methods. Get consolidate() out of main().
"case" is not capitalized.
Move your switch down below the point you are getting the input. You want to set the speed based on what they input and you want to switch on the first char of that entry
switch(roadChoice.charAt(0)) {
If you don't want to deal with the whole char/switch thing, you can always just use if()-else statements with the string data.
That is because it has nothing to do with Java itself. You're just sending a DDL statement to the database. Any difficulties with it would be specific to that database and the JDBC driver.
A and B are not variables themselves. They are two possible values for a variable that you want the user to set. So use a String variable for roadChoice
that you read the input into. Then you can use roadChoice.charAt(0)
to check the first character as a char value.
I'm writing a program for C++ and I must be missing something.
Yes, you are missing the fact that this is someone else's two year old thread and it's in Java, not C++.
You don't need to re-create all of those things when you pick another file for the table. Just create a new table model from that file and use setModel() to set the JTable to the new model. There is no reason to discard the GUI components themselves.
No. Change the value of speed separately from your print output.
You misspelled listener.
Hmm, wrong language and 'void main()'... batting zero so far.
For A and B you could use char values, but not string values in the switch. If you use a String, you would have to use if() statements.
Just have the user enter a number for the road type. Then your switch can simply be
switch (roadType) {
case 1:
speed = 50;
break;
case 2:
// ... etc
}
You will have to remove the "final" from your SPEED declaration.
Get riled up easily much?
This isn't me in "shook my cage" mode. You were suggesting that if the system has no value at all, it should be scrapped. I merely pointed out that only a few have voiced a negative view on it and that hardly constitutes a referendum on its uselessness. "Too simple?", yeah I would say so. Too simple to even consider the opinions of the majority don't necessarily equal the opinions of a couple of dissenters.
So there's some more honest feedback for you. Moderators can have opinions too. I'm not really concerned about who is licking what.
She's still about. Just a couple of days ago she popped in for this post in classic form: http://www.daniweb.com/forums/post1047754.html#post1047754
If "unsorted" contains any duplicates, yes. It just can't retrieve the same element from "unsorted" more than once. The first version could use unsorted.get(4)
multiple times if 4 came up as the random number more than once.
It's actually removing the element from "unsorted". It grabs an element randomly between 0 and size()-1.
Yes, those two lines are an example. As you said, you need to use theBoard[][].
If you don't want repeat selections, you can use this instead
keys_Array[i] = (Integer) unsorted.remove( random.nextInt(unsorted.size()) );
Sounds like a job for Google.
You could start with this: http://en.wikipedia.org/wiki/Comparison_of_programming_languages
what are the numbers after test for?
Those are the array indexes. "test" was just a small String array.
You have to cast the Object to Integer if you want to assign it to the array.
keys_Array[i] = (Integer)unsorted.get(random.nextInt(100));
Using generics to type your collections would avoid that.
for(int i=0;i<100;i++){
keys_Array[i] = unsorted.get( random.nextInt(100) );
}
Note that get() is used if 'unsorted' is an arraylist and not an array.
Here's the "Hello World" tutorial for Netbeans from the Sun site:
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/netbeans.html
It walks you through all of that.
Use formatted output then
String[] test = new String[]{"X","","O"};
System.out.printf(" %s | %s | %s ",test[0],test[1],test[2]);
You can also use Random.nextInt(int) for the random int.
Keep in mind that the suggestions tendered so far will allow the chance that an element is selected multiple times. If you don't want that to be possible then you'll need to put additional measures in place to prevent it.
ardav, it seems to me there are only a couple of people complaining about it. The majority haven't said one way or the other, so you really can't assume to know their feelings on it based upon one or two vocal opponents.
The point is, you have a custom renderer - which is not an editor.
Simple way? Not that I know of. JList is not really considered an editing component and doesn't expose methods for it list JTable does. What you need is a cell editor in addition to your renderer.
You could take a look at this guy's blog entry where he builds an editable JList and perhaps modify it to your needs: http://www.jroller.com/santhosh/date/20050607
Or you could use a JTable instead, with a custom cell renderer.
Well boo-hoo to you!! There are a number of DaniWeb members ...
I think you got that backward. It was Jupiter2 who offered those as excuses. Bob only mentioned that he too was older and has injury to deal with, so he knew what that felt like. He was not claiming those as an excuse for anything. You're flaming the wrong side there.
You haven't asked a question. Posting your assignment isn't the same thing. What are you specifically having trouble understanding? What are your thoughts? What have you tried (anything at all)?
You really are confused I guess. Your username would indicate you have Java questions and yet you post in the C++ forum.
Additionally, you seem to have missed the announcements that state we only offer homework help to those who show some effort. I'm not seeing a whole lot of that in your post. You didn't even post a specific question that would indicate you have given the matter any thought at all.
please i want the full code project solving 8 buzzle using depth and breadth first search ind if you can analyses and comparison between both algorithms
i hope as fast as you can
Any other homework you need us to provide ASAP on your demand? Perhaps just post your instructor's email address so we can send it in directly?
If you mean is there any better design I could follow without appending then I'm am not exactly sure because basically I have 4 tickboxes in the gui and when one is ticked the variable in the if statements changes to true. The tricky part is that the result is a complete array and the tickboxes selects what parts of the array should exist in other words different tickbox combinations will result in different arrays. Are there any examples on how I can do this?
I see that you have solved this part already, but I thought I would add a couple of examples of different designs you can use for that.
This one uses a small listener class that takes the list you want to append as a parameter. To map the check box, you create and add one of these listeners with the list you want to associate with that box. See the comments for clarification
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CheckboxDemo {
JCheckBox box1;
JCheckBox box2;
JCheckBox box3;
JTextArea output;
// the lists we will map to the check boxes
List<String> list1 = new ArrayList<String>(Arrays.asList(new String[]{"a","b","c"}));
List<String> list2 = new ArrayList<String>(Arrays.asList(new String[]{"1","2","3"}));
List<String> list3 = new ArrayList<String>(Arrays.asList(new String[]{"x","y","z"}));
// this will hold the "final" list that results from clicks
List<String> resultList = new ArrayList<String>();
public CheckboxDemo() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
JPanel top = new JPanel();
box1 = …
No, check the API: Math.cos(double) The parameter is an angle in radians. You need to convert first or keep currentAngle
in radians.
Yes, those were the calcs that I was referring to. You didn't post the other code. Your speed calcs are using degrees instead of radians.
Note that Math.sin() and cos() take radians for their parameters. 22.5 is perhaps more radians than you want to add to your angle.
I didn't see a single mod around, just an admin.
Sometimes you can't see us...
;)
Er...do you even need to use all those data types??
Well, according to the OP, yes...
i have to write it using stacks and queues and using LinkedList with an iterator
So get to work writing it. Post code and specific questions here when you get stuck.
I would guess you are getting auto-banned for one of the user modes the mibbit client is setting. +iwx = invisible, see wallusers, hide host
Of course it is, unless you fixed that missing brace from main().
You know, it's getting pretty tough to see over your shoulder and know what you're doing there. You might try reposting the code if you fix something. And walk through every brace and find it's matching closing brace.
Well, I'm going to "guess" that your error is around line 128 (you didn't post the error message) and suggest you look more closely at main().
Well, you can but it's rather unwieldy
ArrayList playerinfo = new ArrayList(Arrays.asList(new Object[]{"blah","blah"}));
It would be much cleaner to just make a small static method to build and return the test data.
Walk through and match your braces. Maintaining good, consistent indentation helps a lot to see things like this.
Also be sure to read the errors carefully because they contain line numbers where the problems occur. "Illegal start of expression" is going to indicate an improperly terminated block or expression prior to the point that the compiler complains.