server_crash 64 Postaholic

I'm thinking this is how you would do it: Have three counter variables:

sCount
oCount
hCount

String input = file.readLine();

for (int i=0; i<input.length(); i++)
{
  if (input.charAt(i) == "s")
  {
         sCount++;
  }
  else if (input.charAt(i) == "o")
  {
        oCount++;
  }
  else if(input.charAt(i) == "h")
  {
        hCount++;
  }
}

Of course that String is after you deal with parsing the name of the player
Don't know if that will help

server_crash 64 Postaholic

and does a lot of neat things.

So does java?

server_crash 64 Postaholic

Is there a way I can some how work the StringBuffer in this method, because I'm using substrings, and I guess that would contribute to a performance loss.

public void run()
    {
    	while (true)
    	{
     	   try
      	  {        
      	      	String oldText = adLabel.getText();
				String newText = oldText.substring(1) + oldText.substring(0, 1);
				
				adLabel.setText(newText);
          	  Thread.sleep(250);

          }
             	catch (InterruptedException e)
       		{
           	      stop();
                }
    }
  }
server_crash 64 Postaholic

YOUR RIGHT! I didn't even think of that, and I was wondering why it was kind of jumpy, or seemed laggy. I'll change it to a BufferedString and get back to you on the physically visable performance. Anyways, thank you for pointing that out.

server_crash 64 Postaholic

I started reading this old book about jsp, and I'm having a few problems getting started. First of all, it says that I need to set these environment variables: Java_HOME, and J2EE_HOME. I don't see those, and I don't think their is a need for them, but I can't get this one command line argument going. I'm trying to start the server, but it says cannot find j2ee. Here is what it told me to type at the command line: start j2ee -verbose, but that doesn't work. I have downloaded j2ee4.2, and I have jdk1.5, so what's the problem?

server_crash 64 Postaholic

Are you guys going to get back to this thread? I just discovered it, have the same setup and was really getting into reading the posts and it just stops in the middle. Did server crash´s net get its security?

Nah, I haven't had much time, but now that it is spring break, I might get back to it. I just couldn't get the laptops connected for some reason.

server_crash 64 Postaholic

I used a JLabel, and deleted the first character and added it on the end of the text. Then the thread did the rest. It was kind of cool, bu not as hard as I expected.

server_crash 64 Postaholic

I have even heard that Java has replaced C++ on the AP Programming test.

It has, but that doesn't mean java is replacing C++. I personally think java is the best language around to teach OO concepts, and is very user friendly. I guess I could base that on fact since all Uni's and HS' are teaching it jetzt, and there has to be a reason for that.

server_crash 64 Postaholic

Thank you, it was easier than I thought. I made one with the timer thread, and one with the original thread in sleep mode.

server_crash 64 Postaholic

I have this code that creates a triangle based on user input, which is the base of the triangle. Now, what I want to know, is how could you display the triangle upside down, and have spaces in between the astrix..To see what I'm talking about, compile and run the code:

import java.io.*;

public class Triangles
{
  public static void main(String[] args) throws IOException
  {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	System.out.println("Enter base of triangle(Must be an odd integer)");
	Integer base = Integer.parseInt(br.readLine());
	int counter = base-1;
	for (int i=0; i<base; i++)
	{
		calculateSpaces(counter);
		for (int j=base; j>counter; j--)
		{
			System.out.print("*");
		}
		System.out.println("");
			counter-=2;	
		if (counter < 0)
		{
			break;
		}
	}
   }
	public static void calculateSpaces(int count)
	{
		int spaces = count/2+3;
		for (int i=0; i<spaces; i++)
		{
			System.out.print(" ");
		}
	}
}
server_crash 64 Postaholic

How would you put a scrolling message on your application with a seperate thread, sort of like an advertisment?

server_crash 64 Postaholic

Maybe this site, I didn't look at it too much, but it looked like you might be able to use it.

http://www.mididb.com/

server_crash 64 Postaholic

that didnt really help (no offense).

More help would be appreciated...

I know, I told you the file that would help was accidently deleted.

server_crash 64 Postaholic

yeah I also thought that ... as you name implies :D

lol, that was our goal! We did bog the system down for the rest of the day though.

server_crash 64 Postaholic

My AP Computer Science class was working on a encryption program, and we all ran them at the same time, encrypting about 60 pages. Now, these computers run off of the same server, so we got the usage up to 102%. I tought the server would blow up, but it didn't .

server_crash 64 Postaholic

server_crash, i would really appreciate it if you could post the code.

george, i already know how to monitor memory - i just want to create the pie chart(with colors)

I think I'll post them in attachments, and since one of the classes I accidently deleted, I will post the class files so you can run the program...But that is only if you ask me for the class files.

I'm sorry, but the actuall file that does the drawing of the arcs is the one delted, but I'll still post what I haven't got rid of. Maybe later, I will rewrite that file, so you can see. I do have the class file though, so you could actually decompile it if you knew how.

server_crash 64 Postaholic

Thank you all for the help. I guess I was unclear on what I wanted. I figured out how to do this though. What you do, is simply add a JMenu, to a JMenu, and that makes it to were you can have subcategories.

server_crash 64 Postaholic

I have mediacom, that downloads at like 380 kb/s, and pay 55$ a month. It took 3 months for mediacom to finally come out and hook us up with cable, and we couldn't go with anybody else, because they were the only provider in the area. If I had a choice, I would definately go with roadrunner.

server_crash 64 Postaholic

Pretty good. I think you should make the transition slower, and possibly zoom in on the picture at really slow intervals(looks really cool).

server_crash 64 Postaholic

Have you ever got your processor up to 102% usage?

server_crash 64 Postaholic

Connection: 640 kbs
Download: 76 kb/s

I guess that's pretty good for being on wireless.

server_crash 64 Postaholic

For pie charts, you would use the drawArc() method. I have an example, but I accidently deleted one of the source files, but I still have all of the class files. So, I can post the source files that I do have, if you want. I could also give you the class files so you can run it.

server_crash 64 Postaholic

Im very impressed. I didn't think that would work, but it did. All of those numbers and if statements keep the range of characters inside the printable ranges, instead of using all 255 characters. If I didn't do it that way, it would be EXTREMELY hard to decrypt.

server_crash 64 Postaholic

I got this method that encrypts and decrypts text. All of it works fine, except when it comes to spaces. It doesn't convert the spaces correct. If you take a look at it, you might understand.

import java.util.*;

public class CustomCypher
{
	public String encryptText(String key, String text)
	{
		long finalKey = 0;
		for (int i=0; i<key.length(); i++)
		{
			long tempKey = key.charAt(i);
			tempKey *= 128;
			finalKey += tempKey;
		}
		
		Random generator = new Random(finalKey);
		String returnString = "";
		for (int i=0; i<text.length(); i++)
		{
			int temp = (int)text.charAt(i);
			temp += generator.nextInt(95);
			if (temp > 126)
			{
				temp -= 95;
			}
			returnString += (char)temp;
		}
		
		return returnString;
	}
	public String decryptText(String key, String text)
	{
		long finalKey = 0;
		for (int i=0; i<key.length(); i++)
		{
			long tempKey = key.charAt(i);
			tempKey *= 128;
			finalKey += tempKey;
		}
		
		Random generator = new Random(finalKey);
		String returnString = "";
		for (int i=0; i<text.length(); i++)
		{
			int temp = (int)text.charAt(i);
			temp -= generator.nextInt(95);
			if (temp < 36)
			{
				temp+= 95;
			}
			else if (temp > 126)
			{
				temp -= 95;
			}
			returnString += (char)temp;
		}
		
		return returnString;
	}
}
server_crash 64 Postaholic

I would think a "ready made" shopping cart, would be something you purchase or something. Sort of like those crappy web editors that some schools use for teacher websites.

server_crash 64 Postaholic

I think JSP has that support, not sure.

server_crash 64 Postaholic

Here's a short example of how to shift the text one letter over. I'm trying to do something similar to this, except using a key(the seed), and using random values.

public class CeaserCypher
{
	public String shiftOne(String text)
	{
		long convert = 0;
		String finalResult = "";
		
		for (int i=0; i<text.length(); i++)
		{
			convert = (long)text.charAt(i) +1;
			finalResult += (char)convert;
		}
		
		return finalResult;
	}
}
server_crash 64 Postaholic

Ok, I got the first part which is where you get the "encryption key" from the user, and convert it to a long. The second part, is actually encrypting the text using the random class, and the new converted key as the seed. I'm not following any alogorithm, im trying to come up with my own.

server_crash 64 Postaholic

I'm trying to write this method that takes some parameters from my text editor, and encrypt the text. I got part of it written, but I'm stuck on the next bit.

I got the part where you convert the "key", but I just can't figure out what to do next.

import java.util.*;

public class Encryptor
{
	public String encryptText(String key, String text)
	{
		String finalResult = "";
		
		for (int i=0; i<key.length(); i++)
		{
			long convert = (long)key.charAt(i);
			convert *= 128;
			finalResult += convert;
		}
		
		Random randomNumGenerator = new Random(keyResult);
		String returnString = "";
		
		
		return returnString;
	}
}
server_crash 64 Postaholic

Yes, I know how to create the Menu's and the Menu items, but how do you have menu items with subcategories...Look at this screenshot to see what I'm saying.

server_crash 64 Postaholic

i tried what u said, but the class doesn't exist

I am really sorry, that's a class in C#(syntax looks the same!). My mistake. I do think there is a way of doing this using JNI.

Look at this thread, I think it might help:

http://forum.java.sun.com/thread.jspa?threadID=578911&messageID=2915348

I believe you have to do a bunch of other things besides in java to get the CPU usage.

server_crash 64 Postaholic

Yes, you can get the usage, availible RAM, and stuff like that, using this class:

System.Diagnostics.PerformanceCounter

I don't have any examples handy, or I would post some code.

server_crash 64 Postaholic

I can't seem to remember how you create subitems in the menu's. Does anyone know how?

Like this:

Format --> Color(then like a drop down)
*red
*blue
*green

server_crash 64 Postaholic

No problem; glad I could help! :D

server_crash 64 Postaholic

Where is this boot menu at? I don't think what your seeing is the temperature, it might be the % usage of some process, but not the temperature.

server_crash 64 Postaholic

Do you even have any kind of hardware that gets the temperature?

server_crash 64 Postaholic

use this:

System.out.print();

Just leave off the ln, in println.

server_crash 64 Postaholic

please regard my last message - i figured it out. Is there a way to find the temperature of the cpu?

thanx

Thermometer?

server_crash 64 Postaholic

Well, I got graded down for what the teacher called " being dirty with clay".. :cheesy:

server_crash 64 Postaholic

>I'm in AP Computer Science right now in high school, and I find it very easy.
Everything in high school is easy. University courses are considerably more difficult.

I made a 'B' in Art, I didn't find that very easy?

server_crash 64 Postaholic

I would say Java; if you look around you'll notice a lot of classes are being taught in Java. I guess this is because it helps in mastering OO design, and best of all, it's user friendly!

server_crash 64 Postaholic

I'm in AP Computer Science right now in high school, and I find it very easy. I guess the best way to go, would be find out what language they will be teaching the year you come up, and start learning early. Don't be fooled by the "AP", those classes really aren't as hard as people make then out to be. But take as many as you can, and don't forget honors, take all honors classes. All of those classes help you get into college.

server_crash 64 Postaholic

You guys, need to thank me for softening the program up for you.

server_crash 64 Postaholic

Hope you guys don't mind me saying anything, but I really like (I think it's the VB.NET naming conventions)...Java from what I read wants you to do this just for a simple button:

startButton;

which in VB.NET, the proper way was this:

btnStart;

I think this is much more logical and simpler...Their idea was to precede it with a three letter representation of the component.

server_crash 64 Postaholic

I've been outsmarted by a girl. I deserve to die. :sad:

server_crash 64 Postaholic

Thank you, I like the link :cheesy:

server_crash 64 Postaholic

Me either I thought you just sat at your computer all day. JK

I do? There's no joking in that.

server_crash 64 Postaholic
static int countChars( String str, char searchChar ) {
                  // Count the number of times searchChar occurs in
                  // str and return the result.
                int i;     // A position in the string, str.
                char ch;   // A character in the string.
                int count; // Number of times searchChar has been found in str.
                count = 0;
                for ( i = 0;  i < str.length();  i++ ) {
                    ch = str.charAt(i);  // Get the i-th character in str.
                    if ( ch == searchChar )
                       count++;
                }
                return count;
            }
server_crash 64 Postaholic

Are you repainting or graphing something?

server_crash 64 Postaholic

Here's a common example:

static int countChars( String str, char searchChar ) {
                  // Count the number of times searchChar occurs in
                  // str and return the result.
                int i;     // A position in the string, str.
                char ch;   // A character in the string.
                int count; // Number of times searchChar has been found in str.
                count = 0;
                for ( i = 0;  i < str.length();  i++ ) {
                    ch = str.charAt(i);  // Get the i-th character in str.
                    if ( ch == searchChar )
                       count++;
                }
                return count;
            }