at first I had terms.add(null); which I thought was the problem, then I replaced it with terms.add(coeff); terms.add(expo); and after each time I used Sop(terms); and it has the same result.
Type: Posts; User: Pinares
at first I had terms.add(null); which I thought was the problem, then I replaced it with terms.add(coeff); terms.add(expo); and after each time I used Sop(terms); and it has the same result.
Okay, I fixed the output loop problem, now I'm still having trouble with my insert method:
public void insert(int coeff, int expo)
{
for(int i = 0; i < terms.size(); i++)
...
It does not give me a chance to put in another input.
I guess it would be the input variable that controls the loop, i have:
while(input !=null)
but even after just one input, the input window closes and it starts printing. Maybe its the way I set...
Still nothing for any variable on that line, but when I delete everything and just keep this line:
System.out.println("insert method called for " + coeff + " " + expo);
it prints in an...
There is a println() statement at the end of the insert method that was printing earlier, but now not even that shows up. it gives me this message:
Exception in thread "main"...
So here is my latest insert method:
public void insert(int coeff, int expo)
{
if(terms.isEmpty())
{
terms.add(null);
}
Okay. Sorry about that, I was getting a bit frustrated. Right now I am working on my insert method that adds terms to the list in descending order of power, I'm having trouble with the descending...
As of now, the test class, this is what is has to do:
III. The Test Class
The main method of your test class will create a Polynomial object and then read and process a series of operations...
Here's the assignment:
I. The Term Class
Create a class to represent a term in an algebraic expression. As defined here, a term consists of an integer coefficient and a nonnegative integer...
That did it! Thanks a ton.
Nothing happened. The code compiled and ran like it should except for that piece of code. It might as well have not been there.
Same thing happens when I use println() to print the value of play...
How can I check what is returned when the user clicks cancel? and that code does not work. I tried it.
Well clicking cancel normally means the user quit. I guess that's what I was going for when I was using null. Is that right or should I be trying something different?
before i had:
if(userGuess == null)
{
//stuff
}
where userGuess is an int. It said "need int, found <null> incomparable types", so I added a string called play where I stored the userGuess...
I tried if(int == null) but it says i can't compare the two. Would I have to initialize a new variable to compare?
What reserve word do I use for when the user quits? I cannot use null in a boolean because they are incompatible types.
That did it. Here is my new code:
import java.util.Random;
import javax.swing.JOptionPane;
//import javax.swing.JOptionPane;
/**
* A class to play the game of Bagels
* @John Pinares
I have to program a game called Bagels. This is how it is suppose to go:
-------------------------------------------------------------------------------
This assignment is to write an interactive...
Its because the test class does not know which input goes to which position. I'm sure I have to implement the counter into the test class. I don't know how though, like in the first input, the test...
Okay, now regardless of the input, right or wrong it gives me this message in the out put right after it prints the user input:
"The combination to MasterLock is JAP
The user entered combo is JAP...
I actually fixed the printing problem. Now the prototype program runs fully but I still can't get the arguments in the setPosition method to match the ones in the lock class. I know the counter is...
I cannot do that since I have to declare input2 before I print it, and since it is declared in the input it does not get the chance to print the length. As soon as type the second character and press...
So the string "input2" is longer than 1 character?
For starters, I have no clue how to use the counter IV. I'm trying to create a combo lock with a 3 letter combo. in my test class I try to use the setPosition() method to try out a random or the...