BestJewSinceJC 700 Posting Maven

Where object1 is the variable. I tried doing that, but i get an error ")" Expected on that line, i suspect that it is because anything that is expected in that first slot is expected inside of quotes.

Incorrect. Anything in that first argument has to amount to a String, just like the javadoc says for the drawString method. So you could put "I'm a String!" + object.toString() in that slot if you wanted to. Or you could even put "I'm a String!" + object, I think.

BestJewSinceJC 700 Posting Maven

What is this? "addMessage(java.lang.String Why is this so confusing,
int xPos,
int yPos)"

java.lang.String why is this so confusing does not mean anything. And if you are declaring a method, you cannot do so inside another method. 'main' is a method. You can only declare methods inside of your class.

BestJewSinceJC 700 Posting Maven

It looks ok to me. Pseudocode doesn't really have a "standard" format (that I know of) - if an experienced programmer were writing that pseudocode, it would look a bit different - but I think you covered most of the steps, which is the important thing. A program wouldn't just "input radius" though. You need to prompt the user first, asking them to input the radius, then you need to read that value into the radius variable.

OrangeNaa commented: Thank you so much for your help! I thought no one would help me! =) +0
BestJewSinceJC 700 Posting Maven

Well, I'm out of ideas. If this is the type of thing that you can't wait until tomorrow for, I recommend downloading an IDE such as Eclipse and using the IDE to manage your code. If you can wait until later, then I'm sure someone will realize what's going on.

If you want to post both of your classes I can paste them into Eclipse and try to help you further, but as of now, I don't know.

BestJewSinceJC 700 Posting Maven

. . What? You'll have to rephrase whatever you just said. Sorry.

BestJewSinceJC 700 Posting Maven

As you said yourself, "I have a program called IstackInterface.java" . . but in your IArrayStack class, you called it IStackInterface. The two are different because of the capital 'S'. Rename it.

BestJewSinceJC 700 Posting Maven

Yes. If you have a GridLayout for your JPanel, and you want to change it so that it can display 2x2, you can use the GridLayout class methods to set it that way.

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/GridLayout.html

Look at the setColumns method and the setRows method. If you don't currently have the JPanel set to a GridLayout but you want it to be, then you'd have to use panel.setLayout(new GridLayout(2,2));

BestJewSinceJC 700 Posting Maven

You're going to have to choose a language and begin learning the basics of that language. Regardless of what language you choose, you will have to learn about loops such as for loops, while loops, do while loops, etc. And of course, if statements, if else statements, etc. Once you learn these constructs you won't have so much trouble with this problem.

BestJewSinceJC 700 Posting Maven

Agreed, then. Just wanted to clarify.

BestJewSinceJC 700 Posting Maven

In addition to what raven said, computer graphics is an obvious one. Might want to take GUI programming as well.

BestJewSinceJC 700 Posting Maven

OP:

As a college student, when I go to career fairs and similar events, and talk to employers, the languages that are most often mentioned are C++ and Java as far as non-Web development goes. I don't know about web development. . AJAX seems to be popular as well as the usuals.

BestJewSinceJC 700 Posting Maven

I don't do these conversions the way you do, I do it the first way that is shown on this link. But your way is described there as well if you're having trouble with it.

http://www.wikihow.com/Convert-from-Decimal-to-Binary

BestJewSinceJC 700 Posting Maven

So a Java interface is more important than a Java Object in your opinion? Since the purpose of object oriented programming is to use Objects? If you are talking about interfaces in general then I take that back, but you specifically mentioned Java interfaces. .

BestJewSinceJC 700 Posting Maven

It seems like you already figured out how to get the Characters from the ArrayList and compare them to see if they are the same. Now all you need to do is write a for loop that prints from 1 . . n where n is the number of elements in your ArrayList. But once you get to the index where the Characters are that you were supposed to compare, you need an if statement to decide whether to print out the Character itself or whether to print out the index.

P.S. Masijade wasn't being rude, just straightforward. You seem to have the basic idea down, so if you know how to use a for loop and an if statement, you should be able to do this.

BestJewSinceJC 700 Posting Maven

Put in a main method where you think it should go, then repost your code. Also, you posted two classes in one code block. . I hope that your classes are defined in separate files. You can't define two classes (i.e. your car class and your Inventory class) in the same file unless one is an inner class of the other (but in your case, it is not, and if you don't know about inner classes yet, don't worry about it).

BestJewSinceJC 700 Posting Maven

Other things you should be aware of:


1. The two statements inside of your constructor do not do anything. You assigned inputMile equal to itself and then you assigned outputKm equal to itself. I think you meant to set inputMile to inputField and outputKm to outputField.

private Chapter165(JTextField inputField, JTextField outputField) 
    {
    	          this.inputMile = inputMile; 
                  this.outputKm = outputKm;
    }

2. If you used an IDE, such as Eclipse, a lot of your errors would be made apparent to you right off the bat. For example, the only reason I noticed the logical error in your code above is because I pasted your code into Eclipse and it immediately pointed out that your statement didn't do anything.

3. For example, other things that Eclipse pointed out to me about your code: you declared a variable named "text" inside of your if statement, but you never used that variable. Same thing goes for your variable "milesKm", which you declared in two different if statements but never used in either one.

4. You have statements in your code such as
"double input = Double.parseDouble(outputKm.getText());". If you read the javadoc for that method, you will see that if you pass in a String which cannot successfully be parsed as a double, (i.e. I passed it the String "///"), then it will throw an Exception. Currently, this Exception will crash your program, rendering it unusable. So you will need to read about "try catch" so that you can …

george21 commented: Thank you for all of your help. You explained it very well. +1
BestJewSinceJC 700 Posting Maven

You created an inner class that implements ActionListener, and you defined the actionPerformed method for that inner class. But when you make the following statements:

Chapter165 listener = new Chapter165(inputMile, outputKm);
inputMile.addActionListener(listener);
outputKm.addActionListener(listener);

"listener" is an Object of the class type Chapter165. But in the Chapter165 class, you did not implement the actionPerformed method, and so, your code is not working as you wanted. If you get rid of that inner class, and put your actionPerformed method that you currently have in your inner class into your Chapter165 class, I think it will work.

P.S. if you wanted to do it like you have your code right now, you would need to change the code I posted above to this:

Chapter165 listener = new Chapter165(inputMile, outputKm);
inputMile.addActionListener(new ConvertListener());
outputKm.addActionListener(new ConvertListener());

If you don't understand why that is, feel free to ask questions. You can also read about inner classes and I think you should read about Listeners on sun's tutorials a little more.

BestJewSinceJC 700 Posting Maven

So basically like just copy all the code that setBase had, and put it in with height? I don't mean replacing it I need the two methods. But when I put them together like im pretty much repeating the codes accept one is for base and one is for height. It gives me a error. could u give me an example.

You already have an example in your code. If you look at the Triangle class, you/your teacher (whoever wrote it) declared a variable called 'base'. Then, you declared a method called setBase. If you want to declare a method called setHeight, you would need a variable called 'height' in your Triangle class. Then you would need a method that returns nothing (void) and sets the height. I'll give you one more example. . .

public class Person{
public String age;


public void setAge(String theAge){
age = theAge;
}

}
BestJewSinceJC 700 Posting Maven

We don't do people's work for them. If you read the stickies, you'll notice that we're here to help people learn how to do things themselves. Also, since AVL trees are a data structure, I'm sure google already has the wonders you are looking for.

BestJewSinceJC 700 Posting Maven

Then convert the meters into centimeters by dividing height by 100. Then do the same calculation that you already posted.

BestJewSinceJC 700 Posting Maven

The only problem I really have with Vista is the annoying, consistent 'do you really want to do X activity' messages and the fact that it hogs my RAM (which isn't a problem on my 4GB computer I now have). All I use is ad-aware and I have never had any problems with malware.

I don't know about most of your points, but it seems that you don't know the definition of an opinion. In any case, I have spoken with a number of IT professionals, and they all have claimed that windows' security problems are more due to its popularity than its inherent flaws.

BestJewSinceJC 700 Posting Maven

As far as I recall calling super.paintComponent is going to clear the surface that you are painting on, which is not what you want to do, so I'd erase that line of code. Recompile&run, then tell me what happens.

BestJewSinceJC 700 Posting Maven

Oops, just realized that I never marked this as solved. I'll do that now. Paul - you should start a new thread and describe exactly what you're trying to do and what problem you're facing. You can continue in here if you want, but it will be much harder to get replies.

BestJewSinceJC 700 Posting Maven

What do you mean it won't run because of "public class Calc extends JFrame implements ActionListener"? It looks to me like that is a correct class header, although I haven't written a Java program in awhile. What is the error message the compiler is giving you?

Also, you declared your class as extending JFrame, but then you have a JFrame variable and the first line in the constructor is "frame=new JFrame("Calculator");" That means that the Object itself is-a JFrame, but it also has-a JFrame. In other words, "Calc" itself is a JFrame (because it extends JFrame), but then you created another JFrame (with your frame variable). So you have two JFrames - you can get rid of the variable "frame".

If neither of those two explanations made sense, try deleting your frame variable, and wherever it says "frame.anything", replace the "frame" with "this".

BestJewSinceJC 700 Posting Maven

Vernon and previous posters are correct, keep in mind that the toString() method is usually used to display some description of an Object. You would write your own toString() method if you wanted to do just that . . for example, if you were writing an RPG, your toString might say

"I am a Super Mutant with 15 Health and I do 35 damage."

That's a stupid example, but toString is just a description of the Object. A class called "Shapes" might have a toString() method that was implemented for its subclasses to print out "I'm a circle" or "I'm a triangle".

BestJewSinceJC 700 Posting Maven

What you want to do is draw two rectangles onto a window. What you're doing is creating two JPanels (which is essentially two different windows, not one), both of which have rectangles drawn inside of them, but you're putting the second JPanel on top of the first one - which is why you cannot see the first one. An analogy would be that you take two pieces of paper, draw a rectangle on each piece of paper, and then you put the second piece of paper on top of the first. Yeah, you drew two rectangles, but you can only see one.

To solve this issue, I'd paint the rectangles onto the same JPanel. You can use an Object to keep track of which coordinates you want to paint, and then in paintComponent, you'd paint those coordinates. Or you could set the coordinates (x, y, width, and height) and paint them, then set them again and paint again.

Another approach that could possibly work (but I'm not sure if it will) is to make the JPanel non-opaque. http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComponent.html#isOpaque%28%29 .. to try that approach all you'd have to do is set the top JPanel jpanel.isOpaque(false).

majestic0110 commented: Nice explanation! +3
BestJewSinceJC 700 Posting Maven

Your link to Heisenbugs doesn't exist anymore or was linked incorrectly. http://en.wikipedia.org/wiki/Unusual_software_bug

BestJewSinceJC 700 Posting Maven

Yes, you just plug in the numbers. You'll see that when you plug in n = 3, the first part of the formula immediately becomes 9*T(1) so you're practically already done.

BestJewSinceJC 700 Posting Maven

To elaborate on what llemes said (and he is correct), you are trying to use the following method "public Object[] toArray(Object[] a)" which takes an array of Objects, but you are passing in an array of chars. "char" is a primitive type, not an Object, which is why you are getting the error. On the other hand, the Character class (like every other class), "is-an" Object, so you can use that. Or you could simply use:

Character[] theChars = letters.toArray();

BestJewSinceJC 700 Posting Maven

Just use a for loop that cycles through the entire String one character at a time.

for (int i = 0; i < string.length(); i++){
1. get the current character
2. attempt to parse this character into an integer.
3. add the integer you just parsed into the linked list.
}

For step 1, see the String class documentation's charAt method. http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html

For step 2, you could use the Integer.parseInt method - there is a better way I think - but that would effective also.

BestJewSinceJC 700 Posting Maven

http://www.google.com/search?q=java+image+on+JPanel&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

There are a ton of examples on the web. . "window" is either a JFrame or JPanel though, and Image is the name of the Java class. You can also check out the java tutorial on Images. . http://java.sun.com/docs/books/tutorial/2d/images/

BestJewSinceJC 700 Posting Maven

Since Ezzaral already answered your question - doesn't your code have syntax errors? You didn't specify a type of Exception in the catch block i.e. catch(Exception e). PS, for things like this, usually the best way to find out is to run a small sample program and see what the output is, if you get errors, etc. Nothing wrong with posting it here, just saying.

BestJewSinceJC 700 Posting Maven

Monte Carlo isn't a method, it is the set of algorithms that use repeated random sampling to compute their results, according to wikipedia. So my question is: if that is the case, then don't you have to design an algorithm to estimate the # bottles of Boost before you even begin coding?

BestJewSinceJC 700 Posting Maven

You'll need to clarify your question. Since the JTextArea displays text, I'd imagine it would go something like jTree.getItemAt(index).toString() or something like that. Then you'd append the text to the JTextArea using whatever the correct method is (probably append)

BestJewSinceJC 700 Posting Maven

If you add components after your GUI is initialized (which it looks like you're doing) I think you need to call revalidate() or validate() on the JPanel or JFrame. If you read the revalidate method documentation it might make it clear which one needs to happen, if at all. Or you could just experiment.

BestJewSinceJC 700 Posting Maven

I could be wrong, but my best guess is that if you want to change the file's last modified time (to something arbitrary), this would be OS dependent.

edit: sorry, just realize that doesn't really help you very much either way. Tired over here, I was pretty much thinking out loud. Good luck though, sorry for being unhelpful.

BestJewSinceJC 700 Posting Maven

Either use wikipedia or ask a more specific question. I don't mean to be rude, it's just that any information I can provide can just as easily be found on wikipedia - I just checked the articles out and they aren't very confusing, but if you have any more specific questions about any of those topics go ahead and ask.

BestJewSinceJC 700 Posting Maven

Whenever you do projects like that you should consider all of your options: for example, is your input file guaranteed to input only integers or characters? If so, you could quit on any input that is not an integer, and this would be no different than quitting when you see a character. To do that you would use the Scanner class to try to parse an integer, and on failure, you'd exit your loop.

Anyway, if you follow up on what JavaAddict said and check out the character class, you will definitely find a method that does what you're looking for, which he is aware of (he didn't give you the method name because it's important to learn to read the docs). I *think* you could also use the Unicode character set and see if what is read in is between the range of values that would make it a char a-Z.

PS: I do not think JavaAddict was suggesting the isInteger method - the second poster is either talking about something unrelated or had a different understand of JavaAddict's post than I did. In any case check the methods out for yourself.

BestJewSinceJC 700 Posting Maven

Yeah interfaces are somewhat similar - if your class "implements" the interface, it forces you to include those methods that are defined in the interface itself.

BestJewSinceJC 700 Posting Maven

One thing I noticed right away is that your insertAtIndex function does not have a for loop. If you want to insert a node at the fifth index, then you will need a for loop and you will have to go to the 'next' node four times. (It looks like you are treating your insertAtIndex method as if it were an "add" method (which usually inserts at the end).

And last, I am confused about how to do the remove_Customer function. Can someone help me with the pseudo code for this function?

To remove a customer, you would have to make the node before the customer you want to remove point to the node after the customer. Think about it like this:

You have a list of customers. For simplicity, let's say you have three customers total and you want to remove the middle customer. So you'd have the following data (according to your project description):

Customer1, Customer2, Customer3. Where Customer1->next = Customer2, and Customer2->next=Customer3.

So if you want to remove a customer, what you need to do is take that customer out of your list. To take customer 2 out of your list, you'd need to make customer 1 point to customer 3, then you'd need to "free" customer 2 if you previously allocated memory for that customer. So customer1.next = customer3; The trickiest part of all of this is that you need to use some sort of loop in order to find the customer …

BestJewSinceJC 700 Posting Maven

It's tricky to help you with this without just giving you a working code sample (which is against the rules here). My first attempt would be a little different than nomemory's. .

public int getListCount(ArrayList list){
    int count = 0;
    for (every object in list){
           if the object is an arraylist, count++;
           if the object is an arraylist, count+= getListCount(the object);
     }

     return count;
}

There might be a flaw in that strategy, but none that I can think of off the top of my head. If so, someone will be sure to tear it apart though. Either way, recursion can be difficult to grasp - I'd recommend that you look at some classic examples of recursion, such as how recursion can be used to count the nodes in a binary tree and other data structures type examples that are widely available on the net.

BestJewSinceJC 700 Posting Maven

I placed the loop in there to keep the program "asking for inputs" until a condition was met (i.e. User inputs 'E' or 'e'). But obviously i might have missed something

Yes, but a while loop runs until the condition is no longer true. For example:

int i = 0;

while(i < 10){
System.out.println(i);
i++; // same as i = i + 1;
}

^ The above will print out 0 through 9.
The below code will just continuously print 0.

int i = 0;

while(i < 10){ //I is always less than ten! Just like in your code above where 'moreOrder' is always true! So what's inbetween the brackets just keeps happening.
System.out.println(i);
}
BestJewSinceJC 700 Posting Maven

Black box testing would involve trying to break your code by giving it invalid inputs and making sure it handles them appropriately, as well as giving it valid inputs and making sure it comes up with the right result. So I do not think your code counts as black box testing. . however, that isn't to say your test is invalid, it just isn't black box IMO.

BestJewSinceJC 700 Posting Maven

It'll probably just look indented. Like it is currently being pressed.

BestJewSinceJC 700 Posting Maven

Then use a JPanel for your splash screen, but add the JPanel to a JFrame, and set it to visible.

BestJewSinceJC 700 Posting Maven

setSelected(true) would make a check box checked, setSelected(false) would make the check box unchecked. It does the equivalent for a JToggleButton, so I imagine it'd make it appear pressed if you set it to true.

BestJewSinceJC 700 Posting Maven

That is a lot of code - the short answer is that you'd use a JComboBox. It's fairly simple and there are plenty of examples here: http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html

BestJewSinceJC 700 Posting Maven

There are a lot of tutorials available on the web, some of which were linked to in this forum in the stick that was mentioned before. Use those. Ask questions. Get help.

BestJewSinceJC 700 Posting Maven

I couldn't disagree with you more, PirateTUX. Jurors are forbidden from doing this kind of research because it introduces bias into the process and it takes control away from the court. Anyone who is doing outside research is introducing "facts" which may or may not be true and is researching material which may sway their opinion from what it would have been if they only heard evidence the court decided was admissible (as was stated in the article).

BestJewSinceJC 700 Posting Maven

I did type a consonant on my keyboard. The game just gave no indication that anything had happened at all. This is a UI usability problem. . you could either change the interface to make it more clear how that part of it works, or give some sort of help messages, or more clear directions, etc. Your game looks pretty good, btw.