#include <stdio.h>
#include <stdlib.h>
#include "libsys.h"

struct substantive
{
	char *subst;
	int sex;
};

struct verben
{
	char *verb_k;
	char *verb_gr;
	int art;
};

struct adjektive
{
	char *adj;
};

	char *art[4]={"er","ie","as","en"};

char getch(void)
{
	return _getchar();
}

void randomize(void)
{
	srand(clock());
}

struct substantive namen[]=
{
	{"Gerhard Schröder",1},{"Helmut Kohl",1},{"Rudolf Scharping",1},
	{"Claudia Nolte",2},	{"Johannes Rau",1},{"Wolfgang Schäuble",1},
	{"Joschka Fischer",1},{"Toni Blair",1},{"Kleopatra",2},
	{"Claudia Schiffer",2},{"Hannelore Kohl",2},{"Konrad Adenauer",1},
	{"Michael Jackson",1},{"Karl Marx",1},	{"Helmut Kohl",1},{"Heino",1},
	{"Gerhard Schröder",1},{"Donald Duck",1},{"Madonna",2},{"Jesus",1},
	{"Gott",1},{"Sheryl Crow",2},{"Verona Feldbusch",2},{"Pipi Langstrumpf",2},
	{"Bill Gates",1},{"Bill Clinton",1},{"Cleopatra",2},{"Winnetou",1},
	{"Käpt'n Blaubär",1},{"Rita Süssmuth",2},{"Boris Becker",1},
	{"Lilo Wanders",2},{"Queen Elizabeth",2},{"Lady Di",2},{"Steffi Graf",2},
	{"Frank Zappa",1},{"Dolly Buster",2},{"Mao Tse Tung",1},{"Ghandi",1},
	{"Dalai Lama",1},{"Teufel",1},{"Lenin",1},{"Edmund Stoiber",1},
	{"Ludwig van Beethoven",1},{"Wolfgang Amadeus Mozart",1},
	{"Richard Wagner",1},{"Erich Honecker",1},{"Adam Riese",1},
	{"Bill Clinton",1},{"Josef Stalin",1},{"Willy Brandt",1},
	{"John F. Kennedy",1},{"E.T.",1},{"Donald Duck",1},{"Lothar Matthäus",1},
	{"Hans Dietrich Genscher",1},{"Franz Josef Strauss",1},{"Sting",1},
	{"Hermann Hesse",1},{"Albert Einstein",1},{"Max Planck",1},
	{"Tom Jones",1},{"Heidi Kabel",2},{"Homer Simpson",1},{"Zeus",1},
	{"Helmut Schmidt",1},{"Antje Vollmer",2},{"Politiker",1},{"Papst",1},
	{"Bundeskanzler",1},{"Arzt",1},{"Friseuse",2},{"Teufel",1},
	{"Sandmännchen",3},{"Mutter",2},{"Vater",1},{"Säufer",1},{"Student",1},
	{"Bauer",1},{"Leiche",2},{"Polizist",1},{"Patientin",2},{"Bäcker",1},
	{"Wirt",1},	{"Schlachter",1},{"Baby",3},{"Reporter",1},{"Politiker",1},
	{"Beamtin",2},{"Oma",2},{"Putzfrau",2},{"Blinde",2},{"Wahnsinnige",2},
	{"Mörder",1},{"Psychiater",1},{"Prinz Charles",1},{"Onkel",1},{"Tante",2}
};

struct substantive sachen[]=
{
	{"Haus",3},{"Buch",3},{"Fahrrad",3},{"Schule",2},{"Auto",3},{"Nase",2},
	{"Mund",1},{"Kopf",1},{"Kaffee",1},{"Telephon",3},{"Tasse",2},{"Katze",2},
	{"Hund",1},{"Maus",2},{"Stuhl",1},{"Mann",1},{"Frau",2},{"Kind",3},
	{"Idiotin",2},{"Lampe",2},{"Panzer",1},{"Klavier",3},{"Gitarre",2},
	{"Straße",2},{"Wasser",3},{"Luft",2},{"Feuer",3},{"Erde",2},{"Mond",1},
	{"Sonne",2},{"Bild",3},{"Stadt",2},{"Land",3},{"Fluss",1},
	{"Bundeskanzler",1},{"Ball",1},{"Hut",1},{"Hose",2},{"Hemd",3},{"Tod",1},
	{"Geld",3},{"Tisch",1},{"Hand",2},{"Baum",1},{"Bier",3},{"Ratte",2},
	{"Esel",1},{"Musik",2},{"Blech",3},{"Dose",2},{"Zahn",1},{"Humor",1},
	{"Unterhose",2},{"Gift",3},{"Gesicht",3},{"Fuß",1},{"Auge",3},{"Warze",2},
	{"Ohr",3},{"Kanone",2},{"Milch",2},{"Messer",3},{"Papier",3},{"Haar",3},
	{"Welt",2},{"Motor",1},{"Langeweile",2},{"Grab",3},{"Schnaps",1},
	{"Vogel",1},{"Fisch",1},{"Meer",3},{"Banane",2},{"Brot",3},
	{"Sitzung",2},{"Labor",3},{"Kurzschluß",1},{"Lüge",2},{"Axt",2},
	{"Abstimmung",2},{"Toilette",2},{"Zigarette",2},{"Winter",1},
	{"Torte",2},{"Bahnhof",1},{"Sarg",1},{"Imbiss",1},{"Mund",1},{"Seife",2},
	{"Fernseher",1},{"Flasche",2},{"Eimer",1},{"Uhr",2},{"Irrenhaus",3},
	{"Wüste",2},{"Klumpen",1},{"Glück",3},{"Schiff",3},{"Käse",1},{"Quark",1},
	{"Sommer",1},{"Witz",1},{"Idee",2},{"Nacht",2},{"Dreck",1},{"Meer",3},
	{"Blut",3},{"Herz",3},{"Apfel",1},{"Banane",2},{"Mist",1},{"Atom",3},
	{"Note",2},{"Gehirn",3},{"Gefühl",3},{"Bombe",2},{"Vakuum",3},
	{"Zahl",2},{"Wort",3},{"Programm",3},{"Computer",1},{"Orient",1},
	{"Gabelstapler",1}
};

struct adjektive ad[]=
{
	{"schön"},{"doof"},{"gut"},{"schlecht"},{"gelb"},{"grün"},{"rot"},
	{"blau"},{"schnell"},{"lang"},{"kurz"},{"hell"},{"düster"},{"sanft"},
	{"hart"},{"langsam"},{"bitter"},{"süß"},{"kaputt"},{"nett"},{"groß"},
	{"klein"},{"leicht"},{"schwer"},{"dick"},{"dünn"},{"rund"},{"eckig"},
	{"heiß"},{"kalt"},{"schlau"},{"elektrisch"},{"nass"},{"trocken"},{"ratlos"},
	{"abartig"},{"genial"},{"bestechlich"},{"irr"},{"steif"},{"angespannt"},
	{"laut"},{"leis"},{"warm"},{"wütend"},{"sauber"},{"schmutzig"},{"arm"},
	{"ätzend"},{"langweilig"},{"interessant"},{"erfahren"},{"abgewählt"},
	{"durchgeknallt"},{"angenehm"},{"widerwärtig"},{"willig"},{"mutig"},
	{"schwach"},{"stark"},{"nervend"},{"spießig"},{"alt"},{"neu"},{"spitz"},
	{"stumpf"},{"teuflisch"},{"scharf"},{"lecker"},{"übelriechend"},{"halb"},
	{"ganz"},{"bleich"},{"peinlich"},{"taktlos"},{"gewieft"},{"windig"},
	{"größenwahnsinnig"},{"verrückt"},{"uralt"},{"aalglatt"},{"korrekt"},
	{"kompetent"},{"einfühlsam"},{"tot"},{"schleimig"},{"gestört"},{"hohl"},
	{"beknackt"},{"nackt"},{"barfüßig"},{"schwitzend"},{"laufend"},{"knackig"},
	{"unverschämt"},{"schläfrig"},{"wohlgeformt"},{"kugelförmig"},{"rauh"},
	{"degeneriert"},{"ekelhaft"},{"brutal"},{"gemein"},{"aggressiv"},
	{"aufdringlich"},{"betroffen"},{"geliebt"},{"gehasst"},{"beharrlich"},
	{"unmenschlich"},{"verblödet"},{"wichtig"},{"gigantisch"},{"winzig"},
	{"witzig"},{"komisch"},{"pervers"},{"fett"},{"stinkend"},{"lausig"},
	{"wendig"},{"breit"},{"locker"},{"einzigartig"},{"sterbend"},{"munter"},
	{"ungepflegt"},{"eisern"},{"echt"},{"besser"},{"wild"},{"ächzend"},
	{"frohlockend"},{"unscheinbar"},{"nebulös"},{"skandalös"},{"obzön"},
	{"beschränkt"},{"genervt"},{"hilflos"},{"unwürdig"},{"geleckt"},
	{"betrunken"},{"unwürdig"},{"bissig"},{"verkalkt"},{"senil"},
	{"jungfräulich"},{"ausgeleiert"},{"beleibt"},{"nachtragend"},{"errötend"},
	{"kahl"},{"würgend"},{"abwesend"},{"ruhig"},{"albern"},{"trostlos"},
	{"salzig"},{"lachend"},{"merkwürdig"},{"behaart"},{"leblos"},{"aufgeblasen"},
	{"frech"},{"kopflos"},{"schmierig"}
};

struct verben verb[]=
{
	{"geht","gehen",6},{"steht","stehen",2},{"sitzt","sitzen",2},
	{"spielt","spielen",7},{"singt","singen",2},{"trinkt","trinken",3},
	{"redet","reden",2},	{"liebt","lieben",7},{"schläft","schlafen",2},
	{"ißt","essen",3},{"lacht","lachen",2},{"tötet","töten",7},
	{"lügt","lügen",2},{"fliegt","fliegen",2},{"überfährt","überfahren",7},
	{"sieht","sehen",3},{"hört","hören",3},{"spricht","sprechen",2},
	{"berechnet","rechnen",3},{"schwimmt","schwimmen",2},
	{"zerschneidet","zerschnitten werden",3},{"raucht","rauchen",3},
	{"spaltet","spalten",3},{"verbrennt","verbrennen",2},{"ist","sein",2},
	{"hat","haben",1},{"zerbricht","zerbrechen",3},{"muss","müssen",4},
	{"kann","können",4},{"darf","dürfen",4},{"will","wollen",5},
	{"klaut","klauen",1},{"soll","sollen",4},{"studiert","studieren",3},
	{"reibt","reiben",3},{"liest","lesen",2},{"irrt","irren",2},
	{"spendiert","spendieren",1},{"schlägt","schlagen",3},{"fragt","fragen",7},
	{"zerstört","zerstören",1},{"erschießt","sich erschießen",1},
	{"überlegt","überlegen",2},{"trifft","treffen",7},{"leckt","lecken",1},
	{"wirft","werfen",1},{"vergiftet","vergiftet werden",1},
	{"öffnet","öffnen",1},{"schreit","schreien",2},{"sprengt","explodieren",3},
	{"erwürgt","würgen",7},{"arbeitet","arbeiten",2},{"erlegt","erlegen",1},
	{"putzt","putzen",1},{"stirbt","sterben",2},	{"kauft","kaufen",1},
	{"brüllt","brüllen",2},{"versteht","es verstehen",7},
	{"zertritt","zertreten werden",1},{"verendet","verenden",2},
	{"labert","labern",2},{"kratzt","kratzen",1},{"wird","nichts werden",2},
	{"entkleidet","sich entkleiden",7},{"verbiegt","sich verbiegen",1},
	{"verschenkt","es verschenken",7},{"vergisst","es vergessen",1},
	{"ergreift","greifen",1},{"baut","bauen",1},{"betet","beten",},
	{"rollt","rollen",3},{"bleibt","bleiben",2},{"wäscht","sich waschen",1},
	{"heiratet","heiraten",7},{"hebt","heben",1},{"denkt","nachdenken",2}
};

void end_sach_aus(void);
void nam_aus(void);
void end_nam_aus(void);
void adj_aus(void);
int verb_aus_k(void);
int verb_aus_gr(void);
int zufall(int);

int main()
{
	int vindx;
	int rem=0;
	char end;

	setbuf(stdout, NULL);
	randomize();
	printf("\n\t\t************************");
	printf("\n\t\t* DER ELEKTRISCHE POET *");
	printf("\n\t\t************************\n");
	printf("\n\tCopyright by J. Ahrensfeld & T. Burr");
	printf("\n\n\tFür die Texte ist Ihr Computer verantwortlich :-)\n");
	printf("\n\tZum beenden des Programmes 'x' eingeben!\n");
	printf("\n\tWeiter mit beliebiger Taste!\n");
	end = getch();

	while(end != 'x')
	{
		if(rem >= 10)
			{
				printf("\n\n\tZum beenden des Programmes 'x' eingeben!\n");
				rem = 0;
				if(getch() == 'x')
					break;
			}
		printf("\n\n");
		nam_aus();

		vindx=verb_aus_k();

		switch (vindx)
			{
				case 1: end_sach_aus(); break;

				case 2: adj_aus(); break;

				case 3: end_sach_aus(); break;

				case 4: verb_aus_gr(); break;

				case 5: verb_aus_gr(); break;

				case 6: adj_aus(); break;

				case 7: end_nam_aus(); break;
			}

		printf(".");
		end = getch();
      rem++;

	}
	printf("\n\n\tDas ist das Ende!");
	return 0;
}

int zufall(int max)
{

	return (rand()%max);
}

void adj_aus(void)
{
	printf("%s", ad[zufall((sizeof(ad)/sizeof(*ad)))].adj);
	return;
}

void end_sach_aus(void)
{
		int index;

		index = zufall(sizeof(sachen)/sizeof(*sachen));
		if (sachen[index].sex==1)
			printf("d%s", art[3]);
		else
			printf("d%s", art[(sachen[index].sex)-1]);
		printf(" ");
		adj_aus();
		if (sachen[index].sex==1)
			printf("en %s", sachen[index].subst);
		else
			printf("e %s", sachen[index].subst);
		return;
}

void nam_aus(void)
{
		int index;

		index = zufall(sizeof(namen)/sizeof(*namen));
		printf("D%s", art[(namen[index].sex)-1]);
		printf(" ");
		adj_aus();
		printf("e %s " ,namen[index].subst);
		return;
}

void end_nam_aus(void)
{
		int index;

		index = zufall(sizeof(namen)/sizeof(*namen));
		if (namen[index].sex==1)
			printf("d%s", art[3]);
		else
			printf("d%s", art[(namen[index].sex)-1]);
		printf(" ");
		adj_aus();
		if (namen[index].sex==1)
			printf("en %s", namen[index].subst);
		else
			printf("e %s", namen[index].subst);
		return;
}

int verb_aus_k(void)
{
		int index;

		index = zufall(sizeof(verb)/sizeof(*verb));
		printf("%s ", verb[index].verb_k);
		return (verb[index].art);
}

int verb_aus_gr(void)
{
		int index;

		index = zufall(sizeof(verb)/sizeof(*verb));
		printf("%s", verb[index].verb_gr);
		return index;
}
