Oops, posted at the same time as you Ezzaral.
majestic0110 commented: Helpful-as always! +3
Grn Xtrm commented: Hot girlfriend. Good going man :) +1
Oops, posted at the same time as you Ezzaral.
Well, what is the size of your array when it draws two lines next to each other? Is it one, or two? Do some debugging. If the array's size is two, then no wonder it looks like that. If its one, my theory is kaput, but have you even made this simple check?
http://lmgtfy.com/?q=dead+lock+java
That question has been asked and answered. You don't have to look past page one of google to find a sufficient answer.
If you start the two threads from within the same class I don't see why they wouldn't be able to both access that variable if the variable is a class variable. You could also pass the variable to both threads through some constructor or method, or you could use a static variable and have both threads access that static variable.
If you want to find a specific word from within a file, another way to do it would be to use Scanner's next() method, then use String.equals to see if they match.
I'm not arguing with you, or saying that I do or do not believe you, but reverse engineering software is not something we typically help with here.
Over here it doesnt make a huge amount of difference unless you are going into research or academia, they would rather see industry experience instead.
8k difference isn't huge but it is pretty good. That is a nice chunk of change to have as a boost when you're just starting.
Yes, and they answered your question already. The reason it isn't working is because
Node trailer = new Node("","",null, null);
is invalid because "" and "" are Strings. You did not write a constructor method that takes two Strings followed by two Nodes. Your constructor takes a double, an int, then two Nodes.
You decompiled them? Implying the source code wasn't yours, and we don't give help with reverse engineering.
Einstein couldn't speak fluently when he was nine. His parents thought he might be retarded.
Ok, glad you got it fixed. The reason I thought you didn't know the API was because it looked like you were trying to write words by drawing the lines individually and connecting them. But anyway, my mistake. Mark this solved if you have no more questions.
If you want to implement the hangman images, you should actually use different images, and simply redraw the appropriate image every turn. (i.e. we did hangman for the iphone in my iphone programming class. You can take the images from http://cs491f09.wordpress.com/2009/10/14/assignment-5/ if you want). Based on how many guesses the user got incorrect you'd draw a different image.
Anyway, as far as the game logic goes, I don't know what all this "substring + guess + other substring" stuff is. All you need is two variables for your word: 1) The game word, which does not change 2) the game word which you display (so you edit it with the correct letters as the user guesses them correctly).
When the user guesses a letter you can do the following:
1. Use the String class's indexOf method to determine whether or not the letter that the user guessed is in the word. This is easy because myString.indexOf(myChar) will return -1 if myChar is not in myString.
2. If the character was in the String, then you can use myString = myString.replace(oldchar, newchar) to replace every occurrence of the old character in myString with the new one. Be careful to say the "myString = " part because the method returns a new String, it does not modify the old String.
Also, I should mention that all of this is available knowledge if you go to http://java.sun.com/javase/6/docs/api/java/lang/String.html ... for example, if you read the …
Just use the drawString method to draw your words. g.drawString(parameters go here) http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics.html
You can set the Graphics contexts' font and color and stuff before you draw the string, and it will draw in that font and color. At least so says the API if you read that link.
Once you create an array, you cannot add more indexes to it. If you need a bigger array, you'd have to do what I said in my first post. Just go read about arrays on google.
You can't add slots to an array. It's impossible. You can create a new array with 5 more slots however, and copy in the contents. Although I hope an instructor didn't tell you to do this because it is a bad idea - instead, double the size of the array.
All I can say to this whole post is hahahahah
Because I find your choice of forums to post this on incredibly inappropriate and funny
CarV5 car1 = new CarV5(String carType1, double endMiles1, double startMiles1, double gallonsUsed1, double pricePerGallon1);
{
cT1 = carType1;
eM1 = endMiles1;
sM1 = startMiles11;
g1 = gallonsUsed1;
ppg1 = pricePerGallon1;
}
It's because the above code does not have valid syntax. Are you trying to create a method? If so, it has to be in a form such as:
public void doSomething(String carType1, double endMiles1, double startMiles1, double gallonsUsed1, double pricePerGallon1)
{
cT1 = carType1;
eM1 = endMiles1;
sM1 = startMiles11;
g1 = gallonsUsed1;
ppg1 = pricePerGallon1;
}
If you're trying to put method calls and use variables, etc, it has to be inside of a method.
CarV5 car1 = new CarV5(String carType1, double endMiles1, double startMiles1, double gallonsUsed1, double pricePerGallon1);
^ The above is creating a new Object, but it is not inside of a method, it is being done inside of the class. You have to put it inside of a method, if you want it to be done when you 'run the class', then you'd put it inside of that class's main method.
Your so clever, hows that working out for ya? Bet it doesn't get ya laid.
Put "Website Major" in your resume, and I bet you never get a job. But seriously, the lack of social skills and self motivation is probably a good cue for where your future is going.
I'm in class right now. Wow you guys are coming out of the woodwork in defense of the king eh? There are computers in a java class - nutty concept.
Why do you even go to class? You don't do the homework and then you're on the computer the entire time.
P.S. There is a picture of myself and my girlfriend in my profile, once again, good try with the personal attacks though. 0/2 on personal attacks, 0/1 on homework assignments. ;)
Also, I'm done here, somebody close this before it gets any more out of hand.
Alright, when is the due date though? I need to know if I have enough time to do this as well as my own less important assignments.
Wow, that might have been the single most condescending post in the history of forums. First about my major which is "Website Design and Administration" and I'm only a year and a half in. (html, ccs) And then talking down again at the end. It could have taken you half the time to write the code as it would have to written me your angry ordered list. This is probably the only place in the world you are king so you flaunt it, Mr. Condescension. No reason to be nasty. Thanks.
Jenna
Actually, I'm far from a "king" here, I'm not even a moderator, and I hardly talk to anyone else on the site. Nice try at summing up the overall picture on a site you just registered on, though. Too bad you fail. :( (Get it, you fail at summarizing the situation as well as failing on your assignment)
Oh, and I was just light-heartedly joking about the major thing. I'm a computer science major - I wouldn't tell anyone that I am a "computer major". I was poking fun, not calling you an idiot. Had you noticed how I then spent five minutes explaining to you, step by step, exactly how to do your assignment and exactly what you needed to research to do the job, it would have been obvious to you that I was helping you, not making fun of you.
Have a nice day,
:)
What does creating an algorithm have to do with C#? I was unaware that algorithms were language specific.
What is a "website major"? ... Never heard of that one.
Anyway, I'll be more specific since I'm feeling nice today, even though Ezzaral gave you more than enough to figure it out.
1. Create two variables - if the user has to be able to enter integers, then use 'int' variables, if they can enter decimal numbers, then use 'double' variables. Create one variable called highest and one variable called lowest.
2. You need to prompt the user to enter values. You can use System.out.println() to do this. Look it up for examples.
3. You need to use Scanner to read in the value. Look up 'Scanner' on google to learn how to read in (Integers/ Doubles) depending on which of the two you are using (see 1).
4. You need two if statements: one to compare the int/double you just read in to 'lowest' and one to compare it to 'highest'. If it is lower than lowest, store it in lowest. If it is higher than highest, store it in highest.
5. Use System.out.println() to print out the lowest and highest.
I'm pretty confident nobody can spell it out for you more than that, so take it or leave it, but if you can't complete your assignment, it is nobody's fault except your own.
Paste us the error with the line number it's occurring on. Once you do so it'll make it easier for us to help you. :)
Haha funny. Read our stickies and go away.
Also, while you're wasting our time, shameless plug for anyone to level this -vote out:
http://www.daniweb.com/forums/search542099.html
edit: Thanks :)
No, we can't code for you. If you want help ask a detailed question. And if you have no idea at all where to start, start by reading about 2D arrays and think about how they can aid you in creating your "world".
I'm confused - you said you're creating some sort of "binary tree priority queue" but your code looks like it's just intended to be a sorted list of Objects, which are different. Which is it supposed to be?
Also, in your sample run, you added a /4 but it doesn't have a character with it. Don't you have to say a/4 or something similar? Otherwise what happens to the character?
Your question has been asked and answered around a thousand times online. If you want the exact code, find it on google. Otherwise read this, it explains the answer.
http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html
Well, you can use that method if you're only going to allow the user to enter one character, but you cannot if you're going to allow the user to enter Strings.
You need to look into some of the 'replace' or 'replaceAll' methods, I think. The replace method that takes two CharSequences might work, but I've never used it. But once you look at that, you're going to be confused with how you should create a CharSequence - consider the fact that String implements CharSequence, so you can probably use that method by passing in two Strings as paramaters.
If you enter a "word", you have a bigger problem: the indexOf method that you are using will not work at all. http://java.sun.com/javase/6/docs/api/java/lang/String.html ... indexOf works by finding the index of a character, not of a String.
From the looks of those for loops you'll need to store at temp[row][col] or something similar, but as long as you understand the syntax, you can figure it out from there. Mark as solved if you don't have any more ?s
So what do you need help with? Have you tried it yet? Try it and post what you've got and we'll help.
nextInt returns an int, you need to store it at some index in your temp array. You didn't specify an index to store it into. temp[0][1] is an index, temp[][] is not.
Nobody is going to do your homework for you. You will only receive help here if you show effort on your assignment.
This belongs in a normal thread, not in a code snippet. And I've experienced the same problem in the past, but I did a lot more debugging than you did. For example, when the window is resized, is your paintComponent method called?
I'd start by booting into safe mode and restoring to before you deleted something you obviously shouldn't have. Then get proper virus removal software and use it.
Your statement on line 21 does nothing because 'gallons' is 0. Saying gallonsused++ adds one to gallonsused. Inside your while loop, what you want to be doing is saying gallonsused = gallonsused + gallons. (Or, equivalently, gallonsused+=gallons). You also only need to prompt the user for the gallons used once -- right after the start of the while loop. You have it in there twice.
You have a couple of other mistakes but they are along the same lines. Once you update those that I mentioned I'll come back and see if I can give you some more help.
Use an if statement in your program instead of a while loop and your program will work as expected. You do know how to use while loops vs. how to use if statements, don't you? It seems like you don't.
You can 'wrap' the array by creating a new Float[] array and then in a for loop, add each float primitive type to the Float array.
Use Scanner, not BufferedReader. Create the Scanner then use scanner.nextLine(). Print out the line that nextLine() returns, and you're done. You could use BufferedReader also and just read in bytes while its not = '\n' also, I suppose.
Yes, that's right. And you're going to have to get input from the user asking if they are an institution or individual and how many books they want to buy.
Yes, it works, but like firstPerson said just try it next time.
You could also use
public static float afp = (float)2.34; //or any decimal value
Haha, most of those were pretty good. Thanks for sharing.
Nobody is going to write anything for you. Especially when that description made no sense to begin with. But read the rules and go away.
I thank really really much! I like it when people correct me spotting out all my mistakes b/c from there, I learn much more than when i am told of my small mistakes. I just have a request that may be you might find silly. I can't do much about it b/c i am new in java and i am kind of a slow learner. Could you clarify the getUncensoredWord, setUncensoredString, and the reset methods. I don't get them that much. And i don't know how they would relate to the Runner class.
I am sorry for my disturbances.
The purpose of the "setUncensoredString" method is so that you can store your uncensored word in a StringCensor Object by calling theCensor.setUncensoredString(theUncensoredString). The purpose of "getUncensoredString" method is so that you can later retrieve your uncensoredString -- so the getUncensoredString method is supposed to return your uncensored String. That way, even though you declared your variable as "private", you can still figure out what its value is by calling getUncensoredString.
The way that those two methods relate to the Runner class is that they allow you to put your Uncensored String in the StringCensor class, which helps you keep track of the String, set the String, get the String, and whatever other methods that you define in the StringCensor class.
Now, the reason you needed a "reset" method was because in your Runner class, you were asking the user for the uncensored String, but then you were overwriting …
They're being removed because you said
if(Balls.get(X).intersects(Balls.get(Y)) == false) {
Balls.remove(X);
}
That doesn't make logical sense to me. It should be if that == true, then remove one. It's going to be false almost all the time. Your statement removes X every time X and Y don't intersect, whereas you stated above that you want to remove X every time X and Y do intersect.
public class StringCensor {
// Declare all the variables going to be needed
private String duplicateUncensoredWord, uncensoredWord, substring;
private String bannedWord;
// a new stringCensor is constructed
public StringCensor()
{
}
public String getUncensoredWord(){
//get the uncensoredWord
}
public void setUncensoredString(String s){
//set the uncensored string
}
public void reset(){
//reset the uncensoredWord that you modified before so that it is the original version again.
}
// the string the user enters is declared
public void userString(String x)
{
//Modify this method so that the uncensoredString (x) is saved in TWO places.
//Hint: I already declared a new String variable in your class that you can use to do this.
uncensoredWord = x;
}
// the method which computes the length of what the user entered
public int length()
{
int number = uncensoredWord.length();
return number;
}
// the method to get the starting and ending characters of the bad word
public String substring(int beginIndex, int endIndex)
{
return substring;
}
// the method to return the index of the first occurence of the word to
// be banned starting from aSubstring
public int indexOf(int aSubstring)
{
return aSubstring;
}
// the method to return the index of the first occurence of the word to
// be banned starting from beginIndex
/* public int indexOf(int aSubstring, int beginIndex)
{
return beginIndex;
}*/
// the method which sets the bad word
public void bannedWord(String theBannedWord)
{
bannedWord = theBannedWord;
}
}
Ok, so I left four methods unimplemented in your …
Ok, so I'm going to explain a bunch of things to you while I go through your code - some of them do not make your code "wrong", but they make it harder to understand and harder to debug. So don't take offense, some of this might seem nitpicky, but it would be stupid of me to help you and not point out everything I notice along the way.
1. Your variable named "whatTheUserPut" is not descriptive and doesn't tell anyone anything about the variable itself. For example, a better variable name would be uncensoredString, since it is the String before it gets censored.
2. Class names, by convention, never start with a lowercase letter. A lot of professors will take off points for not following convention. A good class name would be StringCensor. It makes it easier to identify that your class name represents an Object, among other things. Btw, the convention is simply that class names are camel case, so I might name my class KylesSuperDuperUtility but never kylesSuperDuperUtility or KylesSuperDuperutility etc.
3. You declared a bunch of variables in the StringCensor class that you never use. For example, you never used these: x, y, bannedWord, numberOfLettersInBannedWord, aSubstring, beginIndex, or censored. That indicates that you don't understand how those variables work, so I'll clear it up for you:
[These are your variable declarations at the top of the StringCensor class]
private String x, y, userInput, bannedWord, numberOfLettersInbannedword, substring;
[This is your method]
No, I've never played. I prefer simple games like connect four :)
And apples to apples is a very fun "relaxed" drinking game
I've never been called a geek to my face, only a nerd. . and only a nerd by my friends (actually maybe acquaintances also). But most of my habits aren't particularly nerdy. Even video games these days are not limited to nerds by any means.
It appears I was confused by your code then. Its really late and I'm still sick but I'll take a look at it for you tomorrow if you'll post all of your classes and methods. I can't do too much without getting an overall picture since I don't immediately see the problem.