User Profile

Collapse

Profile Sidebar

Collapse
milk242
milk242
Last Activity: May 22 '11, 07:50 AM
Joined: Feb 23 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • milk242
    started a topic JCombBox editable?
    in Java

    JCombBox editable?

    I would like to type in an empty ComboBox and when I hit enter, have the item added to the ComboBox. Is this possible?

    I'm assuming I would need some sort of Event Listener to change the ComboBoxModel.

    Any help would be appreciated thanks.
    See more | Go to post

  • milk242
    replied to Null cipher question
    in C
    Thanks everyone, I'm pretty lost on how to check for two carriage returns in a row.
    See more | Go to post

    Leave a comment:


  • milk242
    replied to Null cipher question
    in C
    okay I figured it out by using !cin.eof() for the while condition.

    I'm wondering how I can end the program after the user enters in their sentence in terminal. Right now, when I press enter after a sentence, it doesn't end the program and just waits for me to type more.

    should I put some sentinel condition in the while loop to end program?
    See more | Go to post

    Leave a comment:


  • milk242
    started a topic Null cipher question
    in C

    Null cipher question

    Hi everyone,

    I'm trying to figure out how to encrypt something with a null cipher such as if someone typed "hi", it would put 1 random character in front of 'h' and inbetween 'h' and 'i' and after 'i'.

    so I could do something like this:

    Code:
    int main (int argc, char *argv[], char **env)
    {
    	int c , count = 1;//atoi(argv[1]) ;
    	srand(time(NULL)) ;
    	c = rand() % 94 ;
    	c += 32
    ...
    See more | Go to post

  • After some much needed sleep, I decided to stick with the while loop. It makes my code much more simply and works for my application.

    Thanks to everyone for helping, especially Jos

    Code:
    while (x < isbn.length())
    	{
    		if (isbn[x] == 'X' || isbn[x] == 'x' || isdigit(isbn[x]))
    			x++;
    		else
    			isbn = isbn.erase(x, 1);
    	}
    Feel free to help improve this loop.
    See more | Go to post

    Leave a comment:


  • wow its late, I just get caught up in for loops too much and never really think of while loops. Anyways, I decided to scrap the for and while loops and use a recursive method.

    Code:
    string remove(const string &s)
    {
    	if (s.size() != 0)
    	{
    		if (s.size() == 1)
    		{
    			if(isdigit(s[0]) || s[0] == 'X' || s[0] == 'x')
    				return s;
    			else
    				return "";
    		}
    ...
    See more | Go to post

    Leave a comment:


  • Now I'm wondering how I would process the the string if there were less than 10 digits. Seems like I would have to remove all the things I don't want then get the size of the new string, but seems like I would need to know the size of the string with all the things I don't want from the beginning.
    See more | Go to post

    Leave a comment:


  • advice noted!

    any suggestions on how to make it better? I noticed when I entered a number such as 0-13-613950------X, the program would just halt or possibly be in a infinite loop.

    //edit

    nevermind the last part of it, only occurs when my string has less than 10 digits
    See more | Go to post

    Leave a comment:


  • Thanks to both of you for the explanation and solution!

    I made my new loop:
    Code:
    string isbn = "0-13-613950-X";
    	
    	// Go through isbn, remove any non digits
    	int x = 0;
    	while (x < 10)
    	{
    		if (isbn[x] == 88 || isdigit(isbn[x]))
    			x++;
    		else
    			isbn = isbn.erase(x, 1);
    	}	
    	cout << isbn << endl;
    See more | Go to post

    Leave a comment:


  • Help with a loop that's suppose to remove all non-digits

    Hi,

    I'm having a problem explaining why this loop does what it does.

    Code:
    string isbn = "--0---13-6--15--250-3";
    	
    	// Go through isbn, remove any non digits
    	for ( int x = 0 ; x < 10 ; x++)
    	{
    		if (!isdigit(isbn[x]))
    			isbn = isbn.erase(x, 1);
    	}
    	
    	cout << isbn << endl;
    output is -0-136-15-250-3

    Why doesn't...
    See more | Go to post

  • milk242
    replied to GUI - Change contentpane when button pressed
    in Java
    Thanks for the help!
    but...

    Do you know where I can read up more of the pack method? It sort of does what I want but I'll have more than 1 button on the window, each button should populate the content pane with new fields. The pack() method displays the field and when I press the button again, it'll duplicate the fields. Also it breaks the set size of the window.
    See more | Go to post

    Leave a comment:


  • milk242
    replied to GUI - Change contentpane when button pressed
    in Java
    Sorry for the noob question but how would I do that? What would I put in the parameter of the Window header?...
    See more | Go to post

    Leave a comment:


  • milk242
    started a topic GUI - Change contentpane when button pressed
    in Java

    GUI - Change contentpane when button pressed

    Hi everyone

    I'm trying to change what shows up in the contentpane depending on what button you press. Say you press a button labeled "Customer", it would add textfields to the content pane.

    I thought I could just add the action int eh actionPerformed method but doesn't seem to work.

    Thanks for your help!

    Code:
    public class ButtonDemo extends JFrame implements ActionListener
    {
    ...
    See more | Go to post

  • milk242
    replied to Binary files with array objects help
    in Java
    Thanks for all your help, I added a serializedid to my class to fix the problem
    See more | Go to post

    Leave a comment:


  • milk242
    replied to Binary files with array objects help
    in Java
    Do you have any idea what this means?

    Error reading file Data/Customers/Will.dat.
    java.io.Invalid ClassException: Customer; local class incompatible: stream classdesc serialVersionUI D = -585219468501467 1947, local class serialVersionUI D = -492827965364602 4047
    at java.io.ObjectS treamClass.init NonProxy(Object StreamClass.jav a:546)
    at java.io.ObjectI nputStream.read NonProxyDesc(Ob jectInputStream .java:1552)
    ...
    See more | Go to post

    Leave a comment:


  • milk242
    replied to Binary files with array objects help
    in Java
    So make it Customer[] anotherArray = new Customer[2]; ?

    Also I tried to rework the code... I thought this would work, but it doesn't... any idea?

    Code:
    for (int i = 0; i < 3; i++);
    		{
    			String cusName = null, cusEmail = null, cusPhone = null, cusServ = null;
    			System.out.println("Customer information:");
    			System.out.print("Name: ");
    			cusName = keyboard.nextLine();
    ...
    See more | Go to post

    Leave a comment:


  • milk242
    started a topic Binary files with array objects help
    in Java

    Binary files with array objects help

    I know I'm making a mistake, but I'm wondering if someone could tell me the type of mistake I'm making. I know I can write the whole array to a file, but I want to create separate binary files for each Customer. Then I want to readout the binary file... either one or all of them.

    Could someone help me? Thanks.

    Code:
    Customer[] oneArray = new Customer[2];
    		oneArray[0] = new Customer("John", "[email protected]",
    ...
    See more | Go to post

  • milk242
    replied to Help with a recursion method
    in Java
    Thanks JosAH,

    That really helped a lot!

    And thanks to everyone else!
    See more | Go to post

    Leave a comment:


  • milk242
    replied to Help with a recursion method
    in Java
    Thanks for the help, but I'm learning from a book and would like to figure out this recursion method. I know it would be easier to use iterative method or even regular expression.
    See more | Go to post

    Leave a comment:


  • milk242
    started a topic Help with a recursion method
    in Java

    Help with a recursion method

    Hi everyone,

    I'm trying to write a recursive method that removes vowels from a string. If someone can help me formulate a pseudocode to do this, that would be great.

    So far my code is:
    Code:
    public static void RemoveVowels(String str)
         if str.substring(0,1).compareToIgnoreCase("a" == 0)
         {
              str.replace("a", "");
              RemoveVowels(s.substring(1));
    ...
    See more | Go to post
No activity results to display
Show More
Working...