Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - DoomBringer316

Pages: [1] 2 3 ... 54
1
The Waste Land / Re: C++ garbage
« on: December 20, 2006, 09:44:07 am »
#include<iostream>
#include<string>

using namespace std;

class PhoneNumber
{   
    bool Parse()
    {
        string numbers = "1234567890x";
        string temp = "";
        for ( int i = 0; i < Full.length(); i++ )
        {
            for ( int j = 0; j < numbers.length(); j++ )
            {
                if ( Full == numbers[j] )
                {
                    temp += Full;
                    j = -1;
                    i++;
                    if ( i == Full.length() )
                        break;
                }
            }
        }
        Full = temp;
        int xLoc = Full.find('x');
        int acLoc = 0;
        switch ( xLoc )
        {
        case 10:
            acLoc = 3;
            break;
        case 7:
            acLoc = 0;
            break;
        case -1:
            xLoc = Full.length();
            acLoc = 3;
            if ( Full.length() == 7 )
                 acLoc = 0;
            else if ( Full.length() == 10 )
                 acLoc = 3;
            else
            {
                cout << "too long" << endl;
                return false;
            }
            break;
        default:
            cout << "something else" << endl;
            return false;
        }

        for ( int i = 0; i < Full.length(); i++ )
        {
            if ( i < acLoc )
                AreaCode += Full;
            else if ( i < xLoc )
            {
                Number += Full;
                if ( Number.length() == 3 )
                    Number += '-';
            }
            else if ( i != xLoc )
                Extension += Full;
        }

        return true;
    }

public:
    string Full, AreaCode, Number, Extension;
 
    PhoneNumber()
    {
        Full = "";
        AreaCode = "";
        Number = "";
        Extension = "";
    }

    PhoneNumber(string buffer)
    {
        Full = buffer;
        AreaCode = "";
        Number = "";
        Extension = "";
    }

    bool IsValid()
    {
        return Parse();
    }
};

void main()
{
    PhoneNumber MyNumber;

    string input;

    cin >> input;

    MyNumber.Full = input;
    cout << MyNumber.IsValid() << endl;
    cout << "(" << MyNumber.AreaCode << ")" << " " << MyNumber.Number << "x" << MyNumber.Extension << endl;
    cout << MyNumber.Full << endl;
}

2
The Waste Land / Re: C++ garbage
« on: December 20, 2006, 09:43:42 am »
#include<iostream>
#include<string>

using namespace std;

template<typename T> class Complex
{   
public:
    Complex(T real, T imaginary)
    {
        Real = real;
        Imaginary = imaginary;
    };

    ~Complex()
    {

    };

    friend ostream& operator << (ostream& os, const Complex& object)
    {
        os << object.Real << " + " << object.Imaginary << "i";
        return os;
    };

    Complex operator + (Complex& op2)
    {
        return Complex(Real + op2.Real, Imaginary + op2.Imaginary);
    };

    Complex operator - (Complex& op2)
    {
        return Complex(Real - op2.Real, Imaginary - op2.Imaginary);
    };

    T Real, Imaginary;
};

void main()
{
    Complex<double> MyComplex(10.0, 20.0);
    Complex<double> MyComplex2(10.0, 20.0);
    cout << MyComplex - MyComplex2 << endl;
}

3
The Waste Land / C++ garbage
« on: December 20, 2006, 09:42:55 am »
#include<iostream>

#define NULL 0

using namespace std;

template<typename T>class Vector
{
    T* Data;

    void Swap(int pos1, int pos2)
    {
        if ( pos1 < Size && pos2 < Size )
        {
            T temp = Data[pos1];
            Data[pos1] = Data[pos2];
            Data[pos2] = temp;
        }
        else
            throw "ERROR::VECTOR::SWAP invalid index";
    }
public:
    int Size;

    Vector()
    {
        Size = 0;
        Data = NULL;
    }

    ~Vector()
    {
        delete Data;
        Data = NULL;
        Size = 0;
    }

    T operator [] (int index)
    {
        if ( index < Size )
            return Data[index];
        else
            throw "ERROR::VECTOR::[] invalid index";
    }

    void Insert(T data)
    {
        T* NewData = new T[Size + 1];
        for ( int i = 0; i < Size; i++ )
        {
            NewData = Data;
        }
        NewData[Size] = data;

        Data = NewData;
        Size++;
    }
    //sorts descending for UpDown = 0 and ascending otherwise
    void Sort(int DownUp = 0)
    {
        if ( DownUp == 0 )
        {
            for ( int i = 0; i < Size; i++ )
            {
                for ( int j = i + 1; j < Size; j++ )
                {
                    if ( Data > Data[j] )
                    {
                        Swap(i,j);
                    }
                }
            }
        }
        else
        {
            for ( int i = 0; i < Size; i++ )
            {
                for ( int j = i + 1; j < Size; j++ )
                {
                    if ( Data < Data[j] )
                    {
                        Swap(i,j);
                    }
                }
            }
        }
    }
};

void main()
{
    Vector<int> MyVector;
    int temp;
    try
    {
        for ( int i = 0; i < 10; i++ )
        {
            cout << "Enter number " << i << ": ";
            cin >> temp;
            MyVector.Insert(temp);
        }
        MyVector.Sort();
        cout << endl;
        for ( int i = 0; i < MyVector.Size; i++ )
        {
            cout << MyVector << endl;
        }
    }
    catch( char* ex )
    {
        cout << ex << endl;
    }
}

4
Everything Else / Is this just me
« on: January 29, 2006, 10:24:06 pm »
BACKUPS! STAT!

5
Computers & Video Games / Big Rigs
« on: October 02, 2005, 09:07:43 am »
YOU'RE WINNER!

6
The Pineapple / OMG I am new here.
« on: October 02, 2005, 08:40:30 am »
hey guyz watz goin on in dis forum?!?!

7
Debate Den / Tree Falling
« on: September 23, 2004, 07:49:55 pm »
Quote
Um, wow. I simply answered the question that this whole thread was about. Sorry if you misinterpreted what I said, but it had absolutely nothing to do with what you or anyone else said. And I never said that you said only humans can hear

Um, that wasn't directed towards you.  

8
Debate Den / Tree Falling
« on: September 21, 2004, 07:37:00 pm »
Quote
So if a god can hear it, but we can't it's not a sound? I find that very arrogant of human beings. "If we can't hear it, it ain't real."

Uhh... what? I think you totally missed the point. You do realize the definition of sound was made by humans in the first place, correct? Sound is being described as relative to humans, not to some other creature or being. That's why they gave the human hearing range in the definition to begin with.

9
Debate Den / Tree Falling
« on: September 20, 2004, 07:31:11 pm »
Vibrations capable of being heard by traveling through a medium, not by whether or not there is a set of ears available, I assume. It lists the range of human hearing also to show that the vibration must fall between them to be considered a sound.  

10
Debate Den / Tree Falling
« on: September 20, 2004, 01:33:04 pm »
Sound

Vibrations transmitted through an elastic solid or a liquid or gas, with frequencies in the approximate range of 20 to 20,000 hertz, capable of being detected by human organs of hearing.

~taken from dictionary.com

 

11
Debate Den / Farnehite 9/11 On T.v.
« on: September 13, 2004, 08:50:32 pm »
Quote
I may be the only person here not brainwashed by Liberal parents. My parents warned me about how evil they are. About how they feed off fear and hate us so much and hear what they want to hear all of the time. But I am saved.

Sounds like you were brainwashed by Conservative parents instead.

12
Debate Den / Homosexuals
« on: September 13, 2004, 08:48:36 pm »
Oh, no doubt, but that's not the point. I don't believe (I could be wrong) that any religious establishments allowed a marriage between two of the same sex. That was the point of my argument. And besides, MOST of the country today happens to be Christian.

13
Debate Den / Homosexuals
« on: September 13, 2004, 11:49:03 am »
It's not a question of being ethical; it's a question of what marriage is. The church defines marriage as a union between a man and a woman. Since marriages are associated with the church, I don't believe we should have the federal government ban it, but I'm not so sure about it being called marriage. It's not like I care at all- I am in no way religious and I have nothing against gays. It's just something that's been since the church began.

14
Games / Runescape
« on: September 10, 2004, 08:52:02 pm »

15
Debate Den / Abortion
« on: September 10, 2004, 08:39:42 pm »
Quote
Abortion kills the innocent. Vote for George W. Bush, and he will do what he can to stop this "human right." Nobody has the right to die by someone else's choice. How would you like it if you were an abortion? Remember, EVERY ABORTED FETUS even if the size of a thumb, could be another genius, another doctor, another scientist that could cure cancer, or a Cmonkey.

Hmm, judging by your logic, every aborted fetus could also turn out to be a brutal dictator, a mass murderer, or a serial rapist. If you're going to look at one side of it, you have to look at the other as well.

Pages: [1] 2 3 ... 54