Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

TannerB

@TannerB
About
Posts
9
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Why wait to be outsourced when you can do it yourself?
    T TannerB

    I think if Bob were smarter this could be entirely avoided. All Bob needed to do was allow them to login to his computer, which had access to his work and would have prevented the logs from showing access from China. They would not need his security token that way as well. It's pretty amazing that he even kept the transactions on his work email as well.

    The Lounge question

  • Adding BigInt's
    T TannerB

    //WTF?
    BigInt BigInt::add_bigint(BigInt add)
    {
    int carry = 0;
    int temp;
    bool carry2;
    stack<int> answer;
    vector<int> tempvector;
    vector<int> add_int = add.get_bigint();

    while(bigint\_int.size() > add\_int.size())
         add\_int.insert(add\_int.begin(), 1, 0);
    
    while(bigint\_int.size() < add\_int.size())
         bigint\_int.insert(bigint\_int.begin(), 1, 0);
    cout<<add\_int.size()<<" "<<bigint\_int.size()<<"\\n";
    for(int i = size(); i > 0 ;i--) //<------if I do size - 1 here
    {                                  //the first addition works but not the rest
        temp = add\_int\[i\] + bigint\_int\[i\];
        if(temp >= 10)
        {
            temp -= 10;
            carry2 = true;
        }
        else
            carry2 = false;
    
        answer.push(temp + carry);
        
        if(carry2)
            carry = 1;
        else
            carry = 0;
    }
    
    if(carry)
        answer.push(carry);
        
    while(!answer.empty())
    {
        tempvector.push\_back(answer.top());
        answer.pop();
    }
    BigInt ret(tempvector);
    return ret;
    

    }

    C / C++ / MFC graphics data-structures json question

  • Watching a listbox
    T TannerB

    I have a listbox control that contains one or more directories. How do I watch this listbox to see if something is added or removed to it so I can proceed to update my other controls depending on what changed. I can't see an event that really pertains to this, maybe DrawItem but that seems like a bit of an ugly solution. Thanks, sorry if this doesn't make sense, sleep is needed.

    C# question announcement

  • Mouse Over Event (C Sharp)
    T TannerB

    private void panel1_MouseEnter(object sender, EventArgs e)
    {
    panel1.BackgroundImage = ...
    }

    private void panel1_MouseLeave(object sender, EventArgs e)
    {
    panel1.BackgroundImage = ...
    {

    A simple google search would of gave you the answer to this.

    C# csharp question

  • [Message Deleted]
    T TannerB

    Thanks, must of had a brain fart when I read it.

    Java

  • [Message Deleted]
    T TannerB

    I would assume that by 231 he means 2^31, which is the limitation for a signed int.; As for the question, what you are going to have to do is remember back to gradeschool, when we did longhand arithmetic. 1001 2009 ---- 3010 Write out psuedo code on how to do this, then implement it. isValidBigInt should be easy.

    Java

  • Need a tad of help [modified]
    T TannerB

    I've got this here code I just started today for an assigment, it is all working (so I'm not asking you to do it for me :P). What this code does is it considers any @ to be a backspace and deletes the character before it. I was supposed to use indexOf() and substring() but I thought using regular expressions would be simpler, and a learning experience at the same time. I think my problem right now is that I have stared at it for too long. What I want is for the loop in main to be ran atleast once but it seems weird to have the while(checkForError(input)); ran and then have it ran again in the method fixErrors. Any thoughts on what I could do to fix this would be welcome. Other comments and critiques are always welcome. Thanks, Tanner EDIT: Update at bottom.

    import javax.swing.*;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;

    public class bruce_tanner_A3Q3
    {
    public static void main(String [] args)
    {
    String input;
    do
    {
    input = getString("Enter a string");
    printOutput(fixErrors(input));
    }while(checkForError(input));
    }

    //Returns true if specified string has an error ('@' in it) and false
    //if it does not.
    public static boolean checkForError(String input)
    {
    	Pattern pattern = Pattern.compile("@");
    	Matcher matcher = pattern.matcher(input);
    
    	return matcher.find();
    }
    
    //Prompts the user for a string with the specified input
    //Returns the input string
    public static String getString(String input)
    {
    	String tempString = JOptionPane.showInputDialog(input);
    	return tempString;
    }
    
    //Prints the specified message
    public static void printOutput(String tempString)
    {
    	System.out.println(tempString);
    }
    
    //Fixes any errors in the input string
    public static String fixErrors(String tempString)
    {
    	if(checkForError(tempString))
    	{
    		Pattern pattern = Pattern.compile("\[^@\]\[@?+\]");
    		Matcher matcher = pattern.matcher(tempString);
    
    		while(matcher.find())
    		{
    			tempString = matcher.replaceAll("");
    			matcher = pattern.matcher(tempString);
    		}
    
    		pattern = Pattern.compile("@");				//This block gets rid of any extra @'s left over.
    		matcher = pattern.matcher(tempString);
    		tempString = matcher.replaceAll("");
    
    		return tempString;
    	}
    	return "This string is error free";
    }
    

    }

    I'm not sure whether this was a flash of brilliance or not ;) but it works. New main code:

    public static void main(String [] args)
    {
    String input; //The main

    Java help regex java adobe question

  • Code Optimization
    T TannerB

    Oh dear.. cases totally slipped my mind. Also, I never knew that you could do something like currentLetter = input[i]. I'm assuming that that will access the String as a character array and return the letter at position i?

    Java css algorithms performance tutorial code-review

  • Code Optimization
    T TannerB

    I just finished writing this program, what it does is takes your name and assigns each letter a number and adds them up, ie. Tanner would give you 27 The program then checks to see if the number is one or two digits, which in this case it is two (2 and 7) It then adds those two digits together. Comments explain everything What I would like input on is if anyone could give me a couple pointers on how to optimize my code, make it faster or take away some of the writing to reduce it's length

    import javax.swing.*;

    public class bruce_tanner_A2Q2
    {
    public static void main (String [] args)
    {
    int firstNameTotal = 0;
    int secondNameTotal, thirdNameTotal;
    int currentLetter;

    	String input = JOptionPane.showInputDialog("Numerology Calculator -\\nEnter a Name");
    
    	int inputLength = input.length(); //Checks how long the string is to be used as a maximum in the for loop
    
    	//For loop which
    	for(int i = 0;i < inputLength;i++)
    	{
    		currentLetter = (int)input.charAt(i) % 60; // Converts charAt's return into an integer, modulus 60 for less writing
    
    
    		//Each if statement checks for uppercase and lowercase of each letter
    		//A, J, S
    		if (currentLetter == 5 || currentLetter == 14 || currentLetter == 23
    		|| currentLetter == 37 || currentLetter == 46 || currentLetter == 55)
    		{
    			firstNameTotal++;
    		}
    
    		//B, K, T
    		else if (currentLetter == 6 || currentLetter == 15 || currentLetter == 24
    			 || currentLetter == 38 || currentLetter == 47 || currentLetter == 56)
    		{
    			firstNameTotal = firstNameTotal + 2;
    		}
    
    		//C, L, U
    		else if (currentLetter == 7 || currentLetter == 16 || currentLetter == 25
    			 ||	currentLetter == 39 || currentLetter == 48 || currentLetter == 57)
    		{
    			firstNameTotal = firstNameTotal + 3;
    		}
    
    		//D, M, V
    		else if (currentLetter == 8 || currentLetter == 17 || currentLetter == 26
    			 || currentLetter == 40 || currentLetter == 49 || currentLetter == 58)
    		{
    			firstNameTotal = firstNameTotal + 4;
    		}
    
    		//E, N, W
    		else if (currentLetter == 9 || currentLetter == 18 || currentLetter == 27
    			 || currentLetter == 41 || currentLetter == 50 || currentLetter == 59)
    		{
    			firstNameTotal = firstNameTotal + 5;
    		}
    
    		//F, O, X
    		else if (currentLetter == 10 || currentLetter == 19 || currentLetter == 28
    		 	  || currentLetter == 42 || currentLetter == 51 || currentLetter == 0)
    		{
    			firstNameTotal = firstNameTotal + 6;
    		}
    
    		//G, P, Y
    		else if (currentLetter == 11 || currentLetter == 2
    
    Java css algorithms performance tutorial code-review
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups