BestJewSinceJC 700 Posting Maven

Check is extremely simple actually. If any piece can currently move to the king's position, then the king is in check. Since you already have to implement the ability to allow players to move any given piece to any square (that their piece can move to), deciding if those pieces can be moved to the king's square should be trivial.

For checkmate, it is a little harder, but first decide whether the king can move his piece to a square that puts him out of check (by temporarily 'pretending' the king is at a different square, and seeing if he is in check still, and doing that for every square around him). If he can't, it still might not be checkmate. So now you have to see if there is any piece that can either be moved to a square that blocks the 'check' or that can take the piece that is causing the checkmate.

I suggest you make high usage of the "write a method that does one thing and one thing only" principle. Don't write spaghetti code because that could get you into a world of trouble here.

I actually might write a chess game in Swing when I get a chance just for the heck of it.

kvprajapati commented: cool. +6
adcodingmaster commented: this man is nothing....................................................But THE BEST +1
BestJewSinceJC 700 Posting Maven

Considering mods aren't ever bots, I think it'd be safe to write a quick script to let them do their job quickly. (It can't be that hard to write a check for the user's usergroup?)

BestJewSinceJC 700 Posting Maven

Actually, at the risk of sounding whiny, I retract my statement. But I still believe that new members misuse the down vote system to "spite vote"

BestJewSinceJC 700 Posting Maven

Like the docs say, split does not return the character that was split around. My point in my previous post was that you can easily figure out where the characters were anyway by using a little intuition.

BestJewSinceJC 700 Posting Maven
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ComboBoxFrame extends JFrame {
	/***/ private static final long serialVersionUID = 1L;
	
	private JComboBox b;
	private String s;
	private int x = 0;
	private JButton g[] = new JButton[10];
	private ComboBoxFrame me;
	private String courses[] = 
		{ "Advanced Functions", "Calculus",  "Chemistry", "Physics" };

	public ComboBoxFrame() {
		super("Pick your courses!");
		setLayout(new GridLayout(3, 3));
		me = this;
		b = new JComboBox(courses);

		b.addItemListener( new ItemListener() {
			public void itemStateChanged(ItemEvent event) {
				if(event.getStateChange() == ItemEvent.SELECTED) {
					s = (String) b.getSelectedItem();
					System.out.println(s);
					g[x] = new JButton(s);
					add(g[x]);
					me.validate();
					//g[x].addActionListener(this);
					x++; 
				} } } );
				
		add(b);
	}
	
/**	public void actionPerformed(ActionEvent e) {
		String s;
		for(int x = 0; x < 10; x++) {
			s = courses[x];
			if(e.getSource() == s) remove(g[x]);
		}
	}*/
	
	public static void main(String args[]) { 
		ComboBoxFrame comboBoxFrame = new ComboBoxFrame();
		comboBoxFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
	    comboBoxFrame.setSize( 350, 150 );
	    comboBoxFrame.setVisible( true );
	}
}

Now try.

BestJewSinceJC 700 Posting Maven

I must say i agree. I will do the same in the python forum.. If vegaseat is already there, i needn't bother.

I don't, and I occasionally double post with someone else or vice versa. Serves me right.

:(

BestJewSinceJC 700 Posting Maven

My example was pretty long, but try to grasp the concept and I think you'll be able to complete your program. Again, the basic idea I'm proposing is that you multi-thread your application so that the read() method doesn't block the main thread. I'm not sure of the best way to do this, but I'd first try to create a new Thread in which you'd run the receive() method. Hypothetically, you could also make sure that any time the mouse listener method was called it happened in a different thread, but I don't know how you'd do that (since it depends on an event). So if it was my program I'd try the first option. Anyway I really hope this works out for you. I'm no expert in Socket programming or in multithreaded programming, and everything I said here could be completely wrong. But I know the basic concepts of each, so hopefully that little knowledge will be helpful to you here. Good luck

:)

BestJewSinceJC 700 Posting Maven

Sorry, took too long and couldn't edit my last post. Update:

Ok, so this seems to be the issue: since read() blocks while it waits for input, when the client's receive() method is executed, all subsequent mouse clicks on the client "don't happen" until after the client finishes receiving the data via the read() method. So when you click out of order, you are putting an extra event on the thread which doesn't get executed until after read() is done. What you really want to do is "throw away" the click and pretend it didn't happen at all. But I think you need to multi-thread your application. Hopefully someone else on Daniweb will verify this so that I'm not unintentionally leading you astray, but as of now, I believe this to be accurate.

This code will demonstrate to you what I'm talking about. If you look at the ClientTurn_flag variable, you'd expect that once you click (which calls receive() and sets ClientTurn_flag to false), the next time you clicked on the client's window, it should print out "wasn't client's turn". However, it doesn't do that, since the read() method is blocking the thread. In fact what *I think* happens is this. Lets say you run the program, then click:

1) Click client's window
-At this point ClientTurn_flag is true.
-client sends it's coordinates to the server.
-client calls receive method and waits for the server to take it's turn. The receive method calls read(), …

BestJewSinceJC 700 Posting Maven

I have two family members that bought Acer computers at around the same time. This was less than two years ago; neither computer is being used anymore - they both had to buy new laptops because of crappy parts. Basically the screen completely separated on my dads and I don't know about my sister but she has an HP now. Acer = bad

BestJewSinceJC 700 Posting Maven

Haha. That's pretty funny and extremely nerdy of them.

BestJewSinceJC 700 Posting Maven

I looked through your code, and I don't see a reason why you should be continuously adding and removing the mouse listener. If there is no reason to do so, don't do it. (I.e. it adds nothing to your program's logic, so what use does it have? Your ClientTurn_flag takes care of whose turn it is; you don't need to remove the listener). Other than that I changed the placement of one of your statements, it will likely do nothing though . . If you post the Server's code as well, I will run it and I'll help you debug it.

package game;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;

import javax.swing.*;

public class Clientms2 extends JFrame implements MouseListener
{
	private static final long serialVersionUID = 1L;
	
	JFrame container;
	static InetAddress address;
	static Socket s;
	static String host = "localhost";
	static BufferedOutputStream bos;
	static OutputStreamWriter osw;
	static BufferedInputStream bis;
	static InputStreamReader isr;
	static int port = 5656;
	static String message;
	static boolean ClientTurn_flag = true;
	//static MouseListener l;
	
	static int tempx, tempy;
	static int mouseX, mouseY;
	static StringBuffer x, y;
	
	public Clientms2()
	{
		super("Client 1: Player 1");
		setSize(800, 600);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setResizable(false);
		addMouseListener(this);
	}
		
	public static void main(String args[])
	{
		Clientms2 client = new Clientms2();
		client.setVisible(true);
	}

	@Override
	public void mouseClicked(MouseEvent e) 
	{
		if (ClientTurn_flag)
		{
			mouseX = e.getX();
			mouseY = e.getY();
			removeMouseListener(this);
	
			try 
			{
				address = InetAddress.getByName(host);
				s = new Socket(address, port);
		
			} catch (IOException e1) { e1.printStackTrace();	}
			
			System.out.println("CLIENT SENDS: (" + mouseX + ", " + …
Ezzaral commented: Agreed. +9
BestJewSinceJC 700 Posting Maven

Again: I'm reiterating because I feel very strongly about this.

The 'new' buttons are distracting and unnecessary. They don't add any features to the site - let me explain. If I have already been in a thread, I know approximately where I left off, and there is already an indicator that there are new posts there (the link is dark blue or something) so I know to go back. If I haven't been in a thread before, then I already know I haven't been in there, the link is still blue, and the 'new' button does nothing except tell me what I already know: that I haven't read any posts in there.

So you see - in either case - I don't see what that button contributes except an eyesore. I'm not trying to be rude because I think this site rocks, and I think almost every feature is pretty good layout-wise. . but this one. . ugh.

BestJewSinceJC 700 Posting Maven

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html

Using next() is the easiest way to go and will work for what you are describing. And I'm linking to the documentation because if you read the method description for next(), it will become clear what the method does. Alternatively, you could create a while loop

while(scanner.hasNext()) System.out.println(scanner.next());

And just look at what it prints to answer your question.

javaAddict commented: Good solution +4
BestJewSinceJC 700 Posting Maven

Whatever decision you make, you should be prepared to accept and to deal with the consequences of that decision, regardless of whether the consequences are what you intended. I disagree that your parents are necessarily right. They might have your best interests in mind; however, they also have their own best interests in mind, as Ancient Dragon just inadvertently pointed out.

Also, you shouldn't come on a forum with a question like "should I have sex" when you simultaneously spell everything in your post incorrectly -- my answer is no, you shouldn't.

:)

BestJewSinceJC 700 Posting Maven

The "new" buttons that just started showing up suck. They are annoying to look at and they are unnecessary and they serve little purpose. I can already tell which threads I looked at and I don't care if the thread was posted since the last time I visited the forum (or whatever else it is supposed to mean).

BestJewSinceJC 700 Posting Maven

Einstein couldn't speak fluently when he was nine. His parents thought he might be retarded.

BestJewSinceJC 700 Posting Maven

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.

majestic0110 commented: Helpful-as always! +3
BestJewSinceJC 700 Posting Maven

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

BestJewSinceJC 700 Posting Maven

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.

Grn Xtrm commented: Hot girlfriend. Good going man :) +1
BestJewSinceJC 700 Posting Maven

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.

BestJewSinceJC 700 Posting Maven

Well. . I'm in the U.S., I've had one internship, haven't graduated yet, and accepted 73k starting for when I graduate . . so I guess it depends on how much a Masters degree is worth. But also keep in mind that benefits can mean a whole lot. So if you're making 80,000 but have much better benefits than someone making slightly more, you might be better off. Also, keep interviewing. Interviewing can't hurt since it is a valuable skill, and if you get more offers, you can pick and choose which you think is the best.

BestJewSinceJC 700 Posting Maven

you will have to write a program that reads a 4-digit positive integer from the user and prints out the following information on the screen:

Re-read your project assignment. Pay particular attention to the part that I bolded.

BestJewSinceJC 700 Posting Maven
Character ch = new Character('\u00C3');
char prim = ch.charValue();
System.out.println(prim);

Something I just learned how to do after a quick look up in the Character class documentation. I'm sure if you read some stuff yourself and try some things out, you'll find many more useful methods. http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Character.html

peter_budo commented: Good pointer +11
BestJewSinceJC 700 Posting Maven

The reason it gives you trouble is because when the user enters an integer then hits enter, two things have just been entered - the integer and a "newline" which is \n. The method you are calling, "nextInt", only reads in the integer, which leaves the newline in the input stream. But calling nextLine() does read in newlines, which is why you had to call nextLine() before your code would work. You could have also called next(), which would also have read in the newline.

javaAddict commented: Smart explanation. Couldn't find it. +4
BestJewSinceJC 700 Posting Maven

I'll give you some hints and leave the rest of the work (such as using the definition of theta to come up with the values that prove it's big theta) up to you. But these are just my thoughts, no guarantee that it's correct so listen at your own risk.

Consider that n! = n (n-1)(n-2). . . 1. Now consider that n!, therefore, is < n^n, which can be shown simply by aligning each term in n! and each term in n^n.

Now use the logarithmic property: loga(x^r) = r loga(x)

Then use your theta values after finding them to wrap it up. In fact (if it is true and theta values can be found) you don't even need any other logic, unless it was requested by your instructor.

BestJewSinceJC 700 Posting Maven

Design an application that accepts reader data and produces a count of readers by age groups as follows: under 20, 20-29, 30-39, 40-49, 50 and older."

Essentially these are your requirements and the rest of the paragraph didn't matter whatsoever. I don't really see how we can help without designing the algorithm for you, but as a hint, consider that you only need to do these things:

1. create an array of size 5, one for each of your age groups, anmd initialize each index of the array to 0.
2. read in data and based on what age group each piece of data fits into, add one to the appropriate array index.

BestJewSinceJC 700 Posting Maven

ما هو معنى تقدير برنامج كمبيوتر

I quite agree. Very strongly worded.

BestJewSinceJC 700 Posting Maven

Not that the OP is interested, but in case anyone is, finding the minimum and then finding the maximum takes (n-1) comparisons each for a total of 2n-1 comparisons. The same can be done in about 3n/2 comparisons by doing both at once using pair comparisons.

pair comparisons

Jocamps commented: good point! this is how i would do it anyway :) +3
BestJewSinceJC 700 Posting Maven

Tabemono daisuki.

BestJewSinceJC 700 Posting Maven

I have never done it before. but i know this guy who has whom i have no idea where he is now. but he uploaded this harmless virus into the Talk website and crashed it. all the Letters and words came out looking like Arabic or something ?????? very odd. so the webmaster had to shut down the site. couldn't fix it or anything.. it was awful. do you know how to do it ???

Nobody here is going to help you hack a website. Most people here including myself have never attempted such a thing and therefore could not help if we wanted to.

BestJewSinceJC 700 Posting Maven

For humanity's sake, I hope this Janiceps guy is some random dude messing around rather than expecting answers or actually wanting to do what he's saying.

BestJewSinceJC 700 Posting Maven

Learning daniweb's posting guidelines is useful to your major? What about reading comprehension?

BestJewSinceJC 700 Posting Maven

Lol. Soo much irony.

http://www.mac-sucks.com/switch_why.php

[professional googler/internets troller]

http://themacsucks.com/

BestJewSinceJC 700 Posting Maven

Java, because since I am already reasonably good at it, I'd like to become expert.

BestJewSinceJC 700 Posting Maven

edit - sorry, posted this at the same time as James

int N1, N2, product, PoNoN1, PoNoN2;
PoNoN1=N1+"(POSITIVE)";

You can't store Strings into integers. So declare PoNoN2 as a String, not as an integer. Otherwise use a completely different variable. You have many similar mistakes in your code.

String PoNoN1;
PoNoN1= N1+"(POSITIVE)";

Also, your question didn't make any sense to me. Try to be clear about what you want your program to do, what it is doing, and where you think the problems are in your code. If you can't identify problems in your code, at least paste us some error messages from the compiler, or say where you think trouble might lie, or what you don't understand, etc. Also, name variables according to convention. PoNoN2 is definitely not a good variable name.

BestJewSinceJC 700 Posting Maven

Yeah, I'm hacking in right now. Give me a few minutes and your IP will be unblocked.

BestJewSinceJC 700 Posting Maven

The point is, the existeValor method takes three arguments, but you were only passing in one argument. That will only result in a compiler error - the two are treated as completely different methods. So yes - you are on the right track.

BestJewSinceJC 700 Posting Maven

I'm not scouring the whole thread to point out what you missed - all you have to do is go back and read it again. But I don't understand why you think the fact that an opinion exists makes it the truth. (For example, you keep quoting articles/linking to articles, as if the fact that those articles exist somehow makes the opinions they express true rather than just another opinion).

BestJewSinceJC 700 Posting Maven

I personally like the system. I also think it was well designed as far as the interface. The only thing I don't like is that it is going to discourage people from disagreeing (see: this thread) because they will be down voted just for having a different opinion, (which in my opinion is a mis-use of the system, but that can't be controlled).

BestJewSinceJC 700 Posting Maven

sum=0;
for(i=0;i<n;i++)
for(j=0;j<i;j++)
sum++;
what is the actual running time of this code??

Not positive, but it's probably theta (n * n!) = theta (n^2).
The reason I'd say that is because the outer loop is O(n) and the inner loop is always one less than whatever the value is of the outer loop, so it is something like n (n-1) (n-2) ... 1 = n!

Rashakil Fol commented: nice! +6
BestJewSinceJC 700 Posting Maven

Hold on a second - when did I mention online data backup?

Um, tried Microsoft works back in the bad old days (Windows 3.1) and never touched it since, it was so bad. Wordstar 3.3 was better. So was Easy Writer (called Sleazy Writer by fans). Word Perfect for Windows wasn't bad. Word itself wasn't bad (though over the years it's gotten pretty bloated).

Me, I like being able to work unplugged, so the extra time (Apple claims 7, I get 6+) is useful.

Music/Video editing software - use them all the time. But I'm retiring the music editing software, we are buying a Korg Oasys which includes everything you need to produce your own Audio Compact Discs.

As to the speed difference, you may not have taken into account the FSB speed (most people don't) or the actual screen specifications (Apple screens are generally of higher quality).

And it has an operating system that the New South Wales police don't warn you against (see previous post).

I highly doubt that Dell would put together a machine that was unbalanced by putting in a bottleneck in the FSB, if that is what you are suggesting (which it seems it is). In any case, the FSB speed for both systems is 1066 MHz. . . Not that it matters (if you look into it more, I believe the speed does not determine the actual bandwidth, although I'm no expert). The point is that including video editing, music editing, and …

BestJewSinceJC 700 Posting Maven

OK, so the machine may not be quite the same, but is probably close (horseshoes, hand grenades, and tactical nuclear weapons). But I have a few questions:

1) Did you buy anti-virus software?
2) Did you buy firewall software?
3) Did you buy CD/DVD burning software?
4) Did you buy photo management software?
5) Did you buy Video editing software?
6) Did you buy backup software?
7) Did you buy music editing/recording software?
8) Did you buy an office suite?
9) Do you get 6 plus hours of battery life?

For questions 1 to 7, it's either included with the Mac, or you don't need it (anti-virus). For question 8, Apple's IWord costs $79.00, and it's really nice (Pages, Numbers, & Keynote) while Mail comes with the Operating system (or of course you could download Open Office for free - I have both IWork and Open Office installed, and use both). For my business I use IWork a lot, because it comes with a lot of templates which save me time. I use Open Office for handling incoming documents because it has superior import capabilities (and then it's copy and paste into IWork).

So did you save $200,00? Or did you buy a machine that was priced $200,00 less.

Me, I'm glad I bought my Mac. Quite frankly it's the best computer I've ever had (my previous favorite was my Commodore 64).

Apple may be a pain in the ass in a …

BestJewSinceJC 700 Posting Maven

I typed 72 wpm three times in a row, but made 3 mistakes each time. I also type with two fingers. And who said home row meant anything !?!!?!

edit: got up to 81 wpm with 3 mistakes

BestJewSinceJC 700 Posting Maven

Actually if you compare a Mac against a Dell, same specs, the prices are pretty close.

Not really. After a little research, I found a few articles that agree with your point, but the prices are no longer valid and the points do not apply to average computer users (for example, the average computer user does not need most of the software that comes standard on a mac). I recently (under two months ago) bought a Dell, and I was considering a Mac (not seriously, but I did compare prices). The prices were hundreds of dollars better for Dell. Of course, I was only really including processor speed, RAM, and cache size in my analysis. . I wasn't too worried about the video card, what software comes standard, etc. . so those probably play a factor. But for the average computer user (and I probably require a higher end computer than the average user) a Dell is much more affordable. The most inexpensive Mac that I considered usable for me was over a grand. After building a Dell that had more than enough power and memory, it was around 800.

BestJewSinceJC 700 Posting Maven

You can find all kinds of information on these on google. Top down is typically thought of as breaking your problem into subproblems, then breaking these subproblems into further subproblems until you have methods/functions that do one thing well. Bottom up is a bit harder to explain, here is a link that I think does an ok job, but you're better off researching it yourself. http://nothing.tmtm.com/2002/06/bottom-up-programming/

di2daer commented: nice article +2
BestJewSinceJC 700 Posting Maven

a website would store prices on their own database so that people can't mess with the price.

Professional sites will do that. For example, you aren't going to catch websites for companies like best buy or online businesses such as Amazon that don't check the price against their database when you buy an item. But if you are using a program such as Firebug, I think you can capture and edit web pages - so basically, if you were on a website and were purchasing an item, you could edit the price of the item and then buy it, assuming they did not check to see if the price matched on the server side. I know that is a little off topic from what you were saying, but it is a concern. And illegal to do, obviously.

http://getfirebug.com/

I don't personally use firebug but there's the link to the tool I was talking about.

Oh, and as for your original question, it could be the website doing it I suppose - if they had some way to detect the specs or type of your machine. I guess it would be clever to attempt to charge people using higher end machines a higher price for the same item. Dishonest but still. That might not even be possible, I'm just speculating. There could even be a virus, although that would seem very strange and implausible as well. Have you tried looking at the same website on multiple …

iamthwee commented: props to you for mention firebug. +11
BestJewSinceJC 700 Posting Maven

As to your IT professionals - they are wrong. Which makes them not very professional in my book.

Let me explain the difference in simple terms. .

First of all, calling people "unprofessional" when they are not here to defend their opinion speaks volumes about you, none of it good. Second of all, I have spoken to these people in real life, and I know they are successful and I know they are SMEs, so why would I dismiss their opinion based on something "Mad Hatter" said online? Third, I know what modularity is. Don't patronize me.

:)

majestic0110 commented: Amen, brother :) +0
scru commented: Didn't I tell you guys to just ignore it? +0
BestJewSinceJC 700 Posting Maven

Oh, another thing - you printed the diameter twice, but your project description asks for you to print it once.

OrangeNaa commented: Thank you very much for the help!! Not only did you really help me out, but you came back and made sure you gave me the correct evaluation! It's very appreciated=) Take care!! +0
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

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