Forum Archive

Go Back   3D Realms Forums > General Topics > Programming Forum
Blogs FAQ Community Calendar

Notices

 
 
Thread Tools
Old 05-16-2009, 02:06 AM   #1
Glassagate
I'm new at this, please be kind...
How do I reference the name of an image's "title"?
For example:

Account account1 = new Account(50.00M);
Account account2 = new Account(-7.53M);

Later in my coding, I print a line that has the name
of the account hard coded, and the value, at that
point in the process, referenced with one of these:
{0}. I forget the name of it. Index something or other?
What I want to do is the not have the account's
name thingie hard coded. I'm guessing that I'd have
to use some sort of loop, where with each time through,
only one account would dealt with. So, instead of
("account1 balance is {0}.", Balance)
I could have
("{0} balance is {1}.", [way of referencing object's title], Balance);

I'm sorry if I couldn't explain this well enough.
Glassagate is offline  
Old 05-16-2009, 04:57 AM   #2
IceColdDuke
Re: I'm new at this, please be kind...
Im confused on what your trying to do.

This shouldn't even compile cause of the "m" after the 50.00.
Account account1 = new Account(50.00M);
Account account2 = new Account(-7.53M);

im assuming 50.00 represents money.

so im assuming you want something like this?

Code:
class idAccount {
public:
                                idAccount( string name, int amount );
          void                print_data( void );
          void               GiveMoney( int moneyAmmount )

protected:
          string              name;
          int                  amount;
}

idAccount::idAccount( string name, int amount ) {
              this->name = name;
              this->amount = amount;
}

void idAccount::print_data( void ) {
        printf("Account %s has $%d\n", name.c_str(), amount );
}

void idAccount::GiveMoney( int moneyAmmount ) {
         amount += moneyAmmount;
}

void main( void ) {
        idAccount acct1 = new idAccount( "iceColdDuke", 500 );
        acct1->print_data();
        acct1->GiveMoney( 50 );
        acct1->print_data();
}
Im assuming ur probley using C# the above is in C++ but it should copy over nicely, and the concept is what I think ur trying to accomplish.
Last edited by IceColdDuke; 05-16-2009 at 05:03 AM.
IceColdDuke is offline  
Old 05-16-2009, 06:37 PM   #3
peoplessi

peoplessi's Avatar
Re: I'm new at this, please be kind...
If you checked the other thread, the book I recommended would be a great starting point. But our always helpfull IceColdDuke gave you an good example
__________________
Duke Nukem Forever
Who am I to judge?
peoplessi is offline  
 

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:44 AM.

Page generated in 0.08129001 seconds (100.00% PHP - 0% MySQL) with 17 queries

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

Website is ©1987-2014 Apogee Software, Ltd.
Ideas and messages posted here become property of Apogee Software Ltd.