BestJewSinceJC 700 Posting Maven
if (divmod >= 0.0 || divmod < 0.1)

One of the above two conditions is always true. You wanted to use the && symbol.

if (divmod >= 0.0 && divmod < 0.1)
WesFox13 commented: Very Helpful +2
BestJewSinceJC 700 Posting Maven

Yeah but I have it written down on paper. Let me type it up for you - just give me a few months. Come back in August.

BestJewSinceJC 700 Posting Maven

http://www.rollingstone.com/politics/story/29127316/the_great_american_bubble_machine/

An interesting article, no matter what you make of it. I would have comments but I'm not in the know about many of the issues that were described in the article, so I'll refrain for now. It is a long article though, so if you want to read it, be ready to spend at least 30 minutes on it.

BestJewSinceJC 700 Posting Maven

You're attempting to use the variable 'i' but you never declared that variable. And you also didn't follow any of this site's rules.

BestJewSinceJC 700 Posting Maven

To search a LinkedList you need to use an Iterator. To code an Iterator type "iterator java" into google and read things. To see if one String is equal to another String, use the code I already gave you. In your case, since your 'toWord' is inside your Word class, you'll need to create a getter method that returns the variable. Again, use google if you don't know what a getter method is.

If you simply combine the two ideas I just presented to you, you will easily be able to implement my suggestion.

BestJewSinceJC 700 Posting Maven

Every time you read in a new word from the file, before creating a new Word object, you should search your LinkedList to see if the word is already in it. If it is already in the LinkedList, then you would just add one to the word's count. If it isn't already in the LinkedList, then you should create a new Word Object with a count of 1.

BestJewSinceJC 700 Posting Maven

Reflection is used for a class to examine its own (or another class's) behavior at runtime. For example, while the program was running, you could determine what methods the class has and invoke those methods.

You can find the source code file by figuring out the class name and locating the file with the name "classname.java". You can probably use getResource to find the .java file, although it can be complicated. If, for some reason, you do not know the class name (which you probably should know in advance) you can use the printClassName() example found at the top of the Class documentation.

If you know the String name of the class (like MyClass.java and you have the String "MyClass") then you can use the Class method "forName" to get a Class Object for it. Again, look at the documentation link I sent you on that.

To get the source code the easiest way is what I mentioned above - figure out the name of the class, which you probably know in advance, append ".java" to it using String concatenation, then open the .java file for reading, read in the contents, and display them somehow.

Salem commented: Nice +20
BestJewSinceJC 700 Posting Maven

The difference is that Turbo C has not had an update in more than a decade.

Please tell me you guys are both aliases and this is a joke. How many times do people with experience in a language have to tell you that something (TurboC) is inferior before you believe them? IMO at this point you deserve whatever crappy education you get. If you google "Turbo C" the first result says "Antique Software". Enough said. Learn how to program in something relevant.

jephthah commented: yup +0
BestJewSinceJC 700 Posting Maven

Thanks for that enlightening and philosophical reply.

Nick Evan commented: :D +12
BestJewSinceJC 700 Posting Maven

You just did post a thread...

jephthah commented: haha, he did, didnt he? +0
BestJewSinceJC 700 Posting Maven

Nice fake signature. Also, for the second time in the last few days, surely you realize that your sentence is missing a preposition? I'll help you out: next time say "Please give me some suggestions". Or you could use a relevant topic title instead of telling us what we already know - that you need help with something.

BestJewSinceJC 700 Posting Maven

What do you expect to happen as a result of the input you showed above? What is going wrong? Where in your code are you getting an error - and is it a logical error, or is the code throwing an exception? And what are you trying to do that you are having trouble with? Don't assume that everyone here has intimate knowledge of the TM problem that you have; we aren't in your class. And you need to provide a lot more information to get help.

Salem commented: Many fine points. +20
BestJewSinceJC 700 Posting Maven

Implement the Comparable interface.
http://onjava.com/pub/a/onjava/2003/03/12/java_comp.html
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Comparable.html

Then use the Collections.sort(yourArrayList) method
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#sort%28java.util.List%29

In fact the first link shows the whole process. If you are good at reading method documentation all you need to do is look at the second link, implement that interface (it only has one method), then call Collections.sort(yourArrayList). Otherwise just read the first link and follow directions.

kaushik259106 commented: Nice resource +4
BestJewSinceJC 700 Posting Maven

You're suggested.

BestJewSinceJC 700 Posting Maven

in addition to that, I don't see the urgency.

It refers to the timeframe in which we ignore his question.

BestJewSinceJC 700 Posting Maven

Anybody here a fan of Chuck? I'm a pretty big fan - behind at the moment, but I've seen every episode except the last two. Giving our geeky hero superpowers was a risky move on the show's part, but it is still entertaining so far. I also liked his third (and quickly discarded) girlfriend that he met on the airplane quite a bit, but oh well.

I recently got into Spartacus - probably a pretty mediocre show, objectively speaking, but it wasn't very hard to distract me from my OpSys project, especially with all of the nudity and violence. (I guess the show is either on a special channel or it is on very late at night, I don't know, but I watched via Netflix). I can see myself becoming a netflix on demand (through xbox 360) addict very soon.

BestJewSinceJC 700 Posting Maven

Yeah, down vote me; that'll teach me. I don't think I'm being rude by expecting you to not create multiple threads on the same topic, especially without acknowledging the help you've already received or making an attempt to solve the problem on your own. As a teacher, you should understand that it is courteous to acknowledge the help you've received, regardless of whether or not you think it was helpful. It has nothing to do with whether or not this is homework, it has to do with manners.


P.S. why are you helping a student with a programming question if you obviously don't know any programming yourself? I can't imagine that any programming teachers don't know how to use a for loop. .

jasimp commented: Only the really good ones don't use for-loops...duh ;) +6
BestJewSinceJC 700 Posting Maven

Look up Serializable. You could write your base GUI Object out to file and then read it back in via Serialization.

BestJewSinceJC 700 Posting Maven

Any help you get here follows the same rules. So basically, we consider anything you post here "homework help". Whether or not it is homework really doesn't matter - we're here to help people learn, and we're here to give advice that will help people complete their work themselves, not complete it for them. (Occasionally you'll be so close to the right answer that it'll be given to you, or you clearly made effort so someone will throw you a bone if it is a small piece of code, but in general, don't expect code solutions, expect advice and guidance).

BestJewSinceJC 700 Posting Maven

He said quick help. Any time in the first four years would've qualified.

BestJewSinceJC 700 Posting Maven

Nah. I think I'll pass.

BestJewSinceJC 700 Posting Maven

So do you want the placement of the new line to be randomized? Or do you want it to look a certain way? You've just suggested two different things...

BestJewSinceJC 700 Posting Maven

http://theoatmeal.com/comics/computers

I found that pretty funny, as well as the oatmeal's comic about printers. It might be old news to some of you but I don't frequent the site so I tend to forget it exists until a friend shows me a link.

BestJewSinceJC 700 Posting Maven

Create an interface called ClickHandler. Have all of your classes (that you want to execute code when the thing is clicked) implement the ClickHandler interface. The ClickHandler interface should have one method called handleClick(). Each of your classes can provide their own implementation of handleClick(). Now, in your base class, you can keep an ArrayList of Objects that want to be notified when a click happens. You can then loop through the ArrayList and for each Object in the ArrayList, call the handleClick() method.

edit:
Here is an example of what I am talking about. You can actually credit one of our mods, Ezzaral, with coming up with this example (he gave it to me as advice a year or so ago, I think it might clarify things for you).

import java.util.ArrayList;
import java.util.List;

public class mainTest {

    public static void main(String[] args) {
        Model model = new Model();
        View view = new View();

        /** add the view as a listener */
        model.addListener(view);

        /** do something to the model */
        model.updateSomething();
    }
}

class Model {
    /** list of interested listeners (observers, same thing) */
    List<ModelListener> listeners = new ArrayList<ModelListener>();

    /** add a new ModelListener observer for this Model */
    public void addListener(ModelListener listener) {
        listeners.add(listener);
    }

    /** called internally when you need to tell the observer stuff changed */
    private void fireStuffChanged() {
        for (ModelListener listener : listeners) {
            listener.stuffChanged();
        }
    }

    /** method that results in a change in the model */
    public void updateSomething() …
KirkPatrick commented: Ezzaral had just taught me a bit of this and your comments helped me understand better what is going on, thanks bud. +1
BestJewSinceJC 700 Posting Maven

Ok, I see. This link might be helpful. It'll use a dialog to drop down a box from which the user is forced to choose their option. So you could use the drop down box to force them to choose between S, M, L, X. They already have a code example there.

http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html#input

BestJewSinceJC 700 Posting Maven

Casting a char to an int is not advanced Java, it is basic. And I already gave you the exact code you need to use. In addition to that, all you need to complete your program is a few if statements and a for loop. Use Scanner to read in a String. Look at the example at the top that uses System.in as an argument to the Scanner constructor. You can use either the next() method or the nextLine() method; look at the method docs for those two methods.

P.S.

There is no beginner, intermediate, or expert section. We also don't do people's homework for them. At this point I think I've actually listed everything you need to know to do this problem. If you don't understand specifics of what I said I can help you, but research the topics yourself first.

BestJewSinceJC 700 Posting Maven

No problem. You might want to check out the contains() methods of the Rectangle class. They make it easier to detect which braille character you are clicking on.

BestJewSinceJC 700 Posting Maven

Yeah; after you add the new widget to the JFrame, call myFrame.validate();

BestJewSinceJC 700 Posting Maven

I suppose you could try to draw different sized rectangles and other shapes then. But that's where you're on your own as far as me helping you, because I've only drawn on JPanels before.

If drawing on the buttons proves to be too hard, you could also draw your grid on a JPanel, implement MouseListener, detect the user's button clicks (using MouseListener) and detect whether or not you clicked on a particular button. I wrote code once that did exactly that, but the project is on my other laptop. If it comes to it, I can grab the project and give you an example.

BestJewSinceJC 700 Posting Maven

If you wanted to show all of the results you'd have to do

showResult= showResult + "Found Names: "+found+ "Similarity: " +compare+"Path: "+file.getName();

or, equivalently,

showResult +="Found Names: "+found+ "Similarity: " +compare+"Path: "+file.getName();
BestJewSinceJC 700 Posting Maven

I don't know but if you wait another 3-5 years I'll up this thread with an unrelated question for solidarity's sake.

jonsca commented: Too good +2
BestJewSinceJC 700 Posting Maven

Hoe i can solve this type of error?

What did you call me?

;)

jephthah commented: okay, i lol'd +6
BestJewSinceJC 700 Posting Maven

As long as one brain is on a different CPU...

lol

BestJewSinceJC 700 Posting Maven

Do people who use these API's even know how to program? Ive never used XNA before, but it seems like the average Joe can download it, copy past from some tutorials and make some triple A game title. It kinda pisses me off. If anyone here begs to differ, let me know and why I'm wrong. Like I said Ive never used XNA before or anything similar to it. What if you asked an XNA programmer what try throw catch is, would they be able to answer?

Right, and anyone can be a doctor since modern medicine has CAT scans. Maybe not the best example, but the rationale is the same. Good tools enable programmers to be more efficient, but you still need to know how to understand and apply those tools. Better programmers will be more efficient at using the tools correctly. And being able to use one or two APIs does not make someone a good programmer.

BestJewSinceJC 700 Posting Maven

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/op2.html

Read the section on instanceof. One good use of instanceof is in the equals() method that is inherited from the Object class. Since the method is defined as taking a type Object as a parameter, you need to check that it is of the correct type before casting it to that type - otherwise you would get an error. Read this article for info about how to implement the equals() method if you never have before. In their implementation of the equals method, you'll see that they use instanceof.

BestJewSinceJC 700 Posting Maven

Can someone please close this thread? For the last week I've been hoping it would die, but it seems like every couple days somebody posts a new "solution" in here.

BestJewSinceJC 700 Posting Maven

You might also agree with him if he says 1 + 1 = 3 but that doesn't make it any more true.

BestJewSinceJC 700 Posting Maven

Code snippets should be posted for working code, post a regular thread for questions in the future.

BestJewSinceJC 700 Posting Maven

There is a general set of rules for the site and numerous announcements telling you how to post in this forum. Any one of those things would have clarified that we don't write people's homework. I'll even link you to them.

http://www.daniweb.com/forums/announcement9-2.html
http://www.daniweb.com/forums/faq.php?faq=daniweb_policies

BestJewSinceJC 700 Posting Maven

edit: Sorry for the freepost, I was confused there for a second by the similarity of the previous poster's reply to my first reply.

Anyway, you don't need to create a third list, and really you can do it with either LinkedList or ArrayList since they both extend List. The Collections.sort method is defined as taking a List as its parameter.

BestJewSinceJC 700 Posting Maven

private - only access it in methods of the same class. If you don't like this but want to keep it private, either use get and set methods or you're out of luck.

BestJewSinceJC 700 Posting Maven

Should we assume that you followed the rules, asked a specific question, and showed effort towards solving the problem? Or would you like the working code, freshly baked, straight from [Salem, Ancient Dragon, WaltP, Narue]'s oven? In the latter case you're more likely to get my stale humor instead.

:icon_rolleyes:

romariejhoanna commented: He/She did not help at all.... +0
BestJewSinceJC 700 Posting Maven

the code i provided works, but only if you run it through command line.
you had excess lines that stopped the code from working, in addition, when you get input through command line, they are initially in the form of string. to manipulate them, you need to convert them in numbers, which is what i did and explained where i did so. I hope you can make any use out of the code!

Remember what you just did and never do it again, then you'll be closer to helping people learn. Giving people the "working" code doesn't help them learn. It encourages them to disregard rules, both written and understood, and to have others do work for them instead of learning on their own, which can best be accomplished through trying, failing, and repeating.

I am sorry! Dont take it personally

I don't hold a grudge. As long as you keep the things I mentioned before in mind when posting questions from now on, and as long as you don't tell me I'm bad at doing my job, I'm more than willing to help you.

:)

Salem commented: Well said, WELL SAID!!!!! +19
BestJewSinceJC 700 Posting Maven

This is how I think it works. Like I said before I've never used it. This is simply from reading the Javadocs I looked up on google.

public class RPG{
double variable1;
String variable2;

public static void main(String[] args){ 
RPG myGame = new RPG();
Class myClass = RPG.getClass();
Field myField = myClass.getDeclaredField(variable2);
myField.set(myGame, new Double(10.9));
}

}

And one last time I will warn you against this: I'm almost finished my cmsc degree and I've never encountered a reason to use something like that in Java. None of my teachers have even mentioned it. Maybe some other posters who have worked in industry will disagree, but I see it as a tool that is made available for important, but rare uses. Since you already know what all of your possible variable names are (they are defined in advance, Java is a strongly typed language!) you can just use if statements which are far more clear and almost certainly more efficient.

Olliepop commented: Thanks a lot for all your help! +1
BestJewSinceJC 700 Posting Maven

Or this

double val = .2;
val += .1;
System.out.printf("%.2f", val);
BestJewSinceJC 700 Posting Maven

Read this article. If you have any questions after reading it, post them.

BestJewSinceJC 700 Posting Maven

Never used it, looks simple enough though

http://www.jasypt.org/

BestJewSinceJC 700 Posting Maven

Read about strtok which tells you what function to use to separate a string into tokens. Then use atoi to try to parse the string as an int.

BestJewSinceJC 700 Posting Maven

Whew, for some reason I confused C with objective-c .. of course the array isn't an Object and doesn't have 'size' or 'length'. I feel silly - Next time I'll compile first. Neat trick WaltP.

edit: just so the OP doesn't copy paste, there is a typo in Walt's snippet, the second == should be =

BestJewSinceJC 700 Posting Maven

No Offense but I think you should find yourself a new volunteer job. You are abs. no help at all. I don't expect you to do my homework but at least you should be able to tell me what I am doing wrong and I will try to fix it myself hence volunteers that help. Thank You for all your help. Have a nice day!!!!!!!!

http://catb.org/~esr/faqs/smart-questions.html#code
http://catb.org/~esr/faqs/smart-questions.html#urgent

In my previous post, I was trying to get you to give more information so that I could help you without spending an exorbitant amount of time figuring out why your code is not working. That is your job. The least you can do is tell us what part of your assignment you're stuck on, why you haven't been able to proceed, what errors you are getting (if any), how far your program gets, and what causes the program to fail. If you cannot give us this information then you have not tried and I do not care whether or not you finish your assignment. And "telling off" people like myself who are just trying to help you is very likely to result in nobody helping you with your problem at all.

Ezzaral commented: More of an explanation than they deserved. +10