All pastes #939173 Raw Edit

Miscellany

public cpp v1 · immutable
·published 2008-03-12 02:29 UTC
rendered paste body
#include <cstdlib>#include <iostream>using namespace std;class Person {public:       Person();              bool is_dead;       bool has_stamp(char stamp);              char *name;       char *lname;       char stamps[10];              void add_stamp(char stamp);       void print_stamps();       void change_name(char *nname);       void talk();       void die();};Person::Person() {                 is_dead = false;                 for(int i=0;i < sizeof(stamps)-1;i++) {                         stamps[i] = '0';                 }}bool Person::has_stamp(char stamp) {     for(int i=0;i < sizeof(stamps)-1;i++) {             if(stamps[i] == stamp) return true;     }     return false;}void Person::add_stamp(char stamp) {     for(int i=0;i < sizeof(stamps)-1;i++) {             if(stamps[i] == '0') {                          stamps[i] = stamp;                          break;             }     }     printf("[system] added stamp %c to %s\n", stamp, name);               if(has_stamp('F') && has_stamp('A') && has_stamp('I') && has_stamp('L')) {                            printf("[me] lol you FAIL! DIE!\n");                            die();     }}void Person::print_stamps() {     char stamps_f[10];          int x=0;     for(int i=0;i<sizeof(stamps)-1;i++) {             if(stamps[i] != '0') {                          //x++;                          stamps_f[x] = stamps[i];                                  //printf("[%c:%d:%c]\n", stamps[i], x, stamps_f[x]);                          x++;             }     }          printf("[system] %s has stamps: %s\n", name, stamps_f);}void Person::change_name(char *nname) {     strcpy(name, nname);}void Person::talk() {     printf("[%s] BAAAWWWW\n", name);     }void Person::die() {     is_dead = true;     printf("[system] %s has died! :o\n", name);}/* ... */      Person initp(char *name) {       Person t;              strcpy(t.name, name);              return t;}int main(int argc, char *argv[]){    Person faith = initp("faith");        printf("[me] Hello, %s\n", faith.name);    printf("[me] I give you stamp N\n");        faith.add_stamp('N');        printf("[me] Can we start the interview now?\n[%s] sure\n", faith.name);    printf("[me] okay, so.\n");    printf("[me] What's your name?\n[%s] %s.\n", faith.name, faith.name);    printf("[me] Alright, at least you know your own name.\n[%s] yeah.. >.>\n", faith.name);    printf("[me] erm\n");    printf("[me] So, what're your favorite hobbies?\n");    faith.talk();    printf("[%s] oh sorry.. i do that sometimes..\n", faith.name);    printf("[me] ........okay *stamps F on your head*\n");    faith.add_stamp('F');    printf("[%s] pfft.. whatever..\n", faith.name);    printf("[me] riiight... let's continue >.>\n");    printf("[%s] alright *cough conformist >.> cough*\n");    printf("[me] so what're your hobbies?\n");    faith.talk();    printf("[%s] oh sorry again! >.<\n", faith.name);    printf("[%s] i like having sex... with dogs XD\n", faith.name);    printf("[me] ....what?\n");    printf("[%s] yup you heard right, i fuck dogs\n", faith.name);    printf("[me] ...OOOOOKAY *stamps A*\n");    faith.add_stamp('A');    faith.talk();    printf("[me] so... any other hobbies? ^^;\n");    faith.talk();    printf("[%s] i like having sex... with guys XD\n", faith.name);    printf("[me] ...alright... so how much you cost? ;)\n");    faith.talk();    printf("[%s] oh, umm, $5...\n", faith.name);    printf("[me] I'll keep that in mind... *cough* H for Hoe!\n");    faith.add_stamp('H');    faith.talk();    printf("[%s] bitch.. whatever >.>\n", faith.name);    printf("[me] right... so,\n");    printf("[%s] I LIKE DOGS\n", faith.name);    printf("[me] ......STOP INTERRUPTING!\n");    printf("[%s] I OBJECT!\n", faith.name);    printf("[me] OVERRULED! STFU! >.>\n");    printf("[%s] yes sir.. .-.\n");    printf("[me] now... so i herd u liek mudkips? XD\n");    printf("[%s] oh u..\n", faith.name);    faith.talk();    faith.add_stamp('I');    printf("[me] umm... so... CHOCOLATE RAIN!!!\n");    printf("[%s] MADE YOU TURN YOUR HEAD THE OTHER WAY!\n", faith.name);    printf("[me] OMG FAIL! YOU'RE OUT!\n");    faith.talk();    faith.add_stamp('L');    faith.print_stamps();        printf("[me] OMG.....\n");    printf("[me] OKAY... CUT! CUT!!!! NOTHING TO SEE HERE PEOPLE!!!!! >.<\n");    printf("[fin]\n");        /*faith.add_stamp('A');    faith.add_stamp('I');    faith.add_stamp('L');    faith.print_stamps();        printf("[me] tests now...\n\n")        if(faith.has_stamp('F')) printf("[me] you have F\n");    if(faith.has_stamp('A')) printf("[me] you have A\n");    if(faith.has_stamp('I')) printf("[me] you have I\n");    if(faith.has_stamp('L')) printf("[me] you have L\n");*/        system("PAUSE");    return EXIT_SUCCESS;}