BestJewSinceJC 700 Posting Maven

I think that the way Dani has chosen to do the rep system is good. The fact that some members seem to have gotten the short end of the stick isn't the whole story: if Dani changes the rep system in certain ways, then the only thing that will change is that different members will see it as unfair. For example, if Dani changes the formula so that Ryshad's rep power becomes closer to the other member with 11K posts, the member with 11K posts might see this as unfair (i.e. their posts are no longer worth as much). Similarly, if she changes (for example) the system so that you gain another rep point every six months, then certain members will have enormous rep. Therein lies the problem. What Dani came up with might not be the only good solution, or even the best solution, but it is reasonable.

Edit:

My only suggestion is that perhaps sponsorship should give someone added rep power points, as should being chosen as member of the month (btw, how do we view a list of past 'members of the month'?). Being a sponsor is, in my opinion, a kind thing to do and shows appreciation for the site, so it couldn't hurt to give those people an added rep point for it (and I don't think it'd hurt from a business standpoint either). And being chosen for member of the month means you've done something right.

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

A more feasible way to decide which array to store it in would simply be to use if statements to decide. So

if (myString.equals("arrayName")){
arrayName[someIndex] = someData;
}

Other than that, you could look at the Java Class called "Class" and use some of those methods. Take a look in the "Object" class, it has a method called "getClass" that returns a Class Object. This method might be helpful. I'll warn you though that I don't personally mess around with "Class" so I can't guarantee results. But I recommend avoiding its use if at all possible.

BestJewSinceJC 700 Posting Maven

You get that error because you can't update SWT widgets from anywhere except the SWT Thread. In order to fix this, see these methods:

asyncExec
syncExec

Go to this link, search for "The syncExec() or asyncExec() Methods Do Not Create Threads" and then read everything from there down. They have a code example as well.

BestJewSinceJC 700 Posting Maven

Adity, as I said before, it has been awhile for me. My understanding of a Perspective in Eclipse is that it is a collection of views, whereas a view is basically one window container. Given this information, the following might also be helpful to you:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(String viewID)
BestJewSinceJC 700 Posting Maven
PlatformUI.getWorkbench.showPerspective(perspectiveID, window)

It has been many months since I worked on Eclipse RCP .. but I think that is the correct way to do it. If you look at the methods available to you in the PlatformUI class you can trace those method calls yourself.
http://publib.boulder.ibm.com/infocenter/rsdhelp/v7r0m0/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/PlatformUI.html

BestJewSinceJC 700 Posting Maven

You should only init your JTextFields once in the entire program. Therefore, it doesn't make sense to call initJTextFields from within your showKey method. You should init the JTextFields when the GUI is first created, then you should .add() them to your JPanel.

Here is an example to help you. Notice in the example that in the actionPerformed method, I create a new JTextField. Without that line, the example would have worked. There is no reason to create a completely different JTextField (using new) after the point when you add it to the JPanel:

public class ExampleGUI {
	static JTextField field = new JTextField("Blank");
	static JFrame frame;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		frame = new JFrame();
		JPanel panel = new JPanel();
		frame.add(panel);
		panel.add(field);
		
		field.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent arg0) {
				//Comment the next line and this example will work. This way, it doesn't.
				ExampleGUI.field = new JTextField();
				ExampleGUI.field.setText("Bleh");
			}
			
		});
		
		frame.setSize(300,300);
		frame.setVisible(true);
	}

}
BestJewSinceJC 700 Posting Maven

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

BestJewSinceJC 700 Posting Maven

No problem, just let me know if you need any more help.

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
int i;
for (i= 0; i < array.length; i++){
if (array[i] == '\0') array[i] = '\n';
}

My C coding skills are very rusty but that is the general idea, you might have to tweak it a little bit to make it compile haha (I don't remember if C uses .size or .length for arrays..).

BestJewSinceJC 700 Posting Maven

Because your method definition is wrong.

public void setEmployee(ArrayList Employee)

You defined your setEmployee method as taking an ArrayList Object, not as taking an Employee Object. It should be

public void addEmployee(Employee emp)

And notice I changed the name from set to add, because what you're doing is adding an Employee to the ArrayList, not setting the ArrayList. You should also read through this tutorial because your current assignment is going to be nearly impossible for you to get done unless you read about the topics in that tutorial.

BestJewSinceJC 700 Posting Maven

Because you said

ArrayList<String>

instead of

ArrayList<Employee>

. Your code won't work anyway, though, because your ArrayList is in the wrong place. Your ArrayList of Employees should be an instance variable in your Project class. That means it should look something like this:

public class Project{
//Variable Declarations..
ArrayList<Employee> empArrayList = new ArrayList<Employee>();
//Methods go down here..
}
BestJewSinceJC 700 Posting Maven

When you create a new Employee, you would just say something like

Employee emp = new Employee();
yourArrayList.add(emp);

See the javadoc for arraylist. If your Assignment class needs to be able to list the Projects that are available, then the Assignment class should probably have an ArrayList of Projects. If you need to be able to list what Projects an Employee is involved in, assuming your Project class has an ArrayList of Employees you can use the following:

//Assuming projectsList is an ArrayList of your Projects and someEmployee is
//an Employee Object..
for (Project proj: projectsList){
if (proj.employeesList.contains(someEmployee)){
System.out.println("The employee is part of the project " + proj.projectName);
}
}

One more thing: in order to search for an Employee in any type of Collection (i.e. an ArrayList, etc) you must override the equals() method.

BestJewSinceJC 700 Posting Maven

I agree with closing old threads automatically. If someone has a related question a year later they can make a new thread. The downside (as Vernon mentioned) is losing some good points if someone has something useful to say. But that is a rarity compared to how many times spammers up old threads or people post irrelevant code in them.

BestJewSinceJC 700 Posting Maven

Your Project class should have an ArrayList (or some data structure) to hold Employees in it. That way you will know what Employees are working on what project. As far as the Assignment class, I don't really understand what your teacher has in mind for what an Assignment actually is. Ok so it has a start and stop date. . so what? What else does an Assignment have? What exactly is an Assignment in this context?

BestJewSinceJC 700 Posting Maven

Jtodd, stultuske has already provided you with the correct information. . if you take a look at the Javadoc for Random, you'll see that there is a method defined as "public int nextInt(int n)" that will be helpful in doing what he suggested. Again, the trick is to have that method generate an int for you between 0 and the size of your array. Then you use the int that it returns in order to index your array.

One more thing - by convention, variable names are not capitalized. Only class names are capitalized. (i.e. where you named your variable Number you should probably name it number).

BestJewSinceJC 700 Posting Maven

You can also use scannerInput.nextLine() to grab an entire line of text. I don't understand what exactly you're trying to do though. If you give us some short sample inputs, and tell us what you want to happen after those inputs are read in, that would be helpful...

BestJewSinceJC 700 Posting Maven

hello world only has 10 alphabetic characters, not 11. What exactly do you want your program to do? In any case you can use the Character class's isSpace, isWhitespace methods, etc

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Character.html

BestJewSinceJC 700 Posting Maven

That's because you cannot use "==" except on primitive types. That means you can only use "==" on int, double, float, etc. For Objects, if you use "==" it is just checking to see if the memory address of "login" is the same as the memory address of "" (which is the empty String). Of course, these memory addresses are not the same, so it will never work. Anyway, the correct way to do it is this:

if (login.equals("")){
//do something in here
}
BestJewSinceJC 700 Posting Maven

No problem, glad I could help!

BestJewSinceJC 700 Posting Maven

Like I said, you should change your "set" method to "add". You should also have another method called "remove" that takes a String (the username) and attempts to remove it from the ArrayList. So any time the user logs on, they should be added to the ArrayList (meaning you should call the add method) and any time the user logs off they should be removed from the ArrayList. Keep in mind that it is possible for the user to attempt to log in more than once - your code should ignore the user's login attempts if they are already logged in. The ArrayList class has a contains method that will tell you (by returning true) if your User is already in the ArrayList.

BestJewSinceJC 700 Posting Maven

Ok, I see what you mean now. So on line 100, put

if (login == null) login = new Login(userName);

Putting that will have the effect of only creating a new Login if you haven't already created one before.

BestJewSinceJC 700 Posting Maven

In your Login class, you have a method called set. It should be called "add" because it adds a String to the ArrayList. And I don't see what line you're talking about. What line number is it on (as far as the line numbers to the left of your code that you posted in here)? Because it doesn't seem to be on line ten.

BestJewSinceJC 700 Posting Maven

Use a Scanner. Really, the exact way to do it depends on how your text file is set up, but here is a general tutorial on Scanner.

BestJewSinceJC 700 Posting Maven

Down vote my post all you want, but you shouldn't expect hand holding - being pointed towards the thousands of resources available online about remainders should have been enough. And next time you get help, please be considerate enough to follow our rules, such as posting in code tags and marking the thread solved when you solve your problem.

BestJewSinceJC 700 Posting Maven

Look up what a remainder is on google. Our job isn't to teach basic math.

BestJewSinceJC 700 Posting Maven

How could the remainder of 2/3 be higher than 2?

http://www.icoachmath.com/Controls/Remainder.html

BestJewSinceJC 700 Posting Maven

Re-read my reply. I edited it.

BestJewSinceJC 700 Posting Maven

Your Polynomial class does not have a getEx() method. In order to call the getEx() method it must exist.

edit: It's because your Polynomial class has a Node, and your Node class has a getEx() method. Therefore you must say

poly1.front.getEx()

(assuming your Polynomial is called poly1 and your Node inside that Polynomial is called front)

BestJewSinceJC 700 Posting Maven

Yeah - paste the error message along with the line number.

BestJewSinceJC 700 Posting Maven

Then you would just put this same exact statement:

int	integerInput = Integer.parseInt(JOptionPane.showInputDialog(null, "Please enter the grade (0-100) or -1 to exit"));

into the while loop as well. And in the while loop, you would need to add your "integerInput" numbers into an int array. Kvass gave you basically all of the code. What are you confused about?

Look up how to use arrays in java, how to use while loops in java, and how to use for loops in java. Your teacher spelled out basically everything - his comments tell you what you need to do and the exact spot where you need to do it.

BestJewSinceJC 700 Posting Maven

That is because the way you wrote it doesn't save any of the values after they are read in - in this section of code, you ignore the return value of showInputDialog, hence, you never store the value the user entered, and it is lost.

JOptionPane.showInputDialog(null, "Please enter the grade (0-100) or -1 to exit"));

Furthermore, your code is probably supposed to stop asking the user to input values if the user ever enters -1. But it doesn't do that. It only stops prompting the user for input values if they enter -1 on their first guess; whereas it should stop if they enter -1 for any of their guesses.

I think you should take a closer look at the code that kvass posted for you. Considering that it is correct. I don't see how your text pane could possibly report the correct values when you never stored them anywhere; in kvass's code, he stores the values in an array. If you use kvass's code and modify your text pane code so that it grabs the values from the array (using a for loop), then your text pane will work correctly.

BestJewSinceJC 700 Posting Maven

So a tool bar (you know, the link you would've seen if you'd looked through the last link I sent you)? Sorry if that isn't what you wanted, your post actually still makes no sense, typing in caps doesn't really help though.

http://java.sun.com/docs/books/tutorial/uiswing/components/toolbar.html

Majestics commented: Great Help... +0
BestJewSinceJC 700 Posting Maven

http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html

JMenuBar, then you add JMenuItems to it if I remember correctly. In any case all the info you need is there.

BestJewSinceJC 700 Posting Maven

Your code only works if args.length >= 2 and if the args can be parsed as integers. In short, it is almost useless. As is upping a thread that is 3 years old.

BestJewSinceJC 700 Posting Maven

Object.getClass().getName();

Obviously that won't work on primitive types. But why do you want to do this to begin with?

BestJewSinceJC 700 Posting Maven

CODE TAGS. Use them. Read the rules.

BestJewSinceJC 700 Posting Maven

jwenting is correct and you can find the same explanation on java.sun.com . . JDK is an SDK. They probably just call it JDK instead for the same reason that so many other things in Java have that J.

BestJewSinceJC 700 Posting Maven

You're misunderstanding the concept of a for each loop. Change the code to this:

final int[] message = {60, 80, 100...}
		for(int i: message)
		{
			System.out.print((char)i);
		}
BestJewSinceJC 700 Posting Maven

It is called deleting an element from an array, not deleting the array. Just a little terminology thing - you sounded like you were saying you wanted to delete the entire array. Anyway, you can do this by moving each element back one like you suggested. So you'd need to use a for loop to do that. And you also need to keep track of what index the last element of the array is stored at (since your array probably won't be full, and definitely won't be full after you delete an element)

BestJewSinceJC 700 Posting Maven

Thanks for providing help.

but sir my list is computed in other thread. this thread take 10 - 15 sec to compute the list, meanwhile view come in display and as the thread(list compute) completed, it gets weird for a moment.

Thanks again

Then you need to use a SwingWorker thread. Read this link. You might need to read about Swing & the event dispatch thread first (it is the article right before that one, the list is on the left). SwingWorker is perfectly suited for your task since the point is to execute long running tasks (such as your 10-15s one) in the background, then to update the Swing EDT on what it should do in response. There is also a full example which it links to at the top of the article.

BestJewSinceJC 700 Posting Maven

As long as the list, a swing component, is getting updated by the EDT (the swing thread), not your other thread, everything should work fine. I'm not an expert but that has been my experience. Is that the case? You can test by calling this method in the method where you update the JList. That is just a guess, no guarantee that its good advice, but it is really quick to check.

BestJewSinceJC 700 Posting Maven

Why do you have to use BlueJ? You should be able to write your code in any IDE. If you're concerned that it might not run properly, you could always import the project into BlueJ and run it there to make sure. Also, if you're satisfied with the help you got in here, you can mark the thread as solved.

BestJewSinceJC 700 Posting Maven

In your do while loop just use a counter. So right before you enter the do while loop, declare and initialize a counter with

int counter = 0;

then inside the loop, right before you say "enter any letter", do

counter++;

Then right after the loop ends, do

System.out.println("You guessed " + counter + " times");
BestJewSinceJC 700 Posting Maven

You don't need a boolean array. You need a String. Then you need to iterate over the String, determining if each piece of the String is a character or not. Check out the isLetter method of the Character class. You can determine if a specific piece (i.e. index) of a String is a letter by using the String class's charAt method, then getting that character and using the Character class's isLetter method.

Oh, and for the later part that you mentioned where you need to enter a letter, you can do that as follows:
1. Use the String class's toCharArray method on your String.
2. For whatever character they enter, loop through the array, seeing if the character they entered == the one in the array.

BestJewSinceJC 700 Posting Maven

The first bad habit I noticed is that you initialized your stID array as an array of 100 ints, but then you have this piece of code:

for(int i = 1; i<=numStu;i++){
System.out.println("Enter Student ID: ");
sID[i] = scan.nextInt();
outputFile.println(sID[i]);
}//end of for

If the user enters a number > 100 for numStu, your program will generate an ArrayOutOfBounds Exception and subsequently crash. A better habit would be to prompt the user for the number of students then initialize the array with that number.

i.e.

int[] students = null;
int numStud = scanner.nextInt();
...
students = new int[numStud];

I'm pretty tired right now, didn't sleep last night at all. But that is the general idea.

BestJewSinceJC 700 Posting Maven

Before you leap into GridBagLayout I would strongly advise you to read a little about each of the various Layout Managers. . (GridBagLayout, BoxLayout, GridLayout, etc). I'm pretty sure each of them contains a section explain what they are useful for doing and why. You should choose your layout manager depending on your project's needs. Only choose the harder ones like GridBagLayout if it is necessary for your design.

BestJewSinceJC 700 Posting Maven

For playing sound, you can use the Java Sound API. Specifically, it sounds like the section in this article on Using a Clip is relevant to what you are trying to do.

BestJewSinceJC 700 Posting Maven

What is this supposed to mean?

Q4 myInstanceOfQ4(3,5.5);

I think you should read about classes, methods, and Objects in the Java tutorials.