brauche hilfe bei Header Einbindung



  • Hallo!

    Ich schreib gerade ein Adressbuch und komme nicht mehr weiter wie ich die Termine einbinden soll. Kann mir jemand helfen?

    Das Programm soll folgendes können:
    +Anlegen eines Termines zu einem Kontakt
    +Löschen eines Termines oder Kontaktes
    +Suchen eines Termins oder Kontaktes

    Ich weis einfach nicht wie ich die Termine da noch reinbekommen soll
    Hier die Daten:

    Adressbuch.cpp
    #include "PKontakt.h"
    #include "DKontakt.h"
    #include "Termine.h"
    #include "operations.h"

    int main()
    {
    class operations operations;
    PKontakt pkontakt;
    DKontakt dkontakt;
    char auswahl;

    while(1)
    {
    cout << endl << endl << endl;
    cout << "\t Adressbuch Programm";

    cout << endl;

    cout << "\n1 - Neuen privaten Kontakt speichern";
    cout << "\n2 - Neuen dienstlichen Kontakt speichern";
    cout << "\n3 - Kontakt suchen";
    cout << "\n4 - Alle Kontakte loeschen";
    cout << endl;
    cout << "\nb - Programm beenden";
    cout << endl << endl;
    cout << "Ihre Auswahl: ";
    cin >> auswahl;

    cout << endl << endl;

    switch (auswahl)
    {
    case '1':
    operations.PKontakt_speichern();
    break;
    case '2':
    operations.DKontakt_speichern();
    break;
    case '3':
    operations.Kontakt_suchen();
    break;
    case '4':
    operations.Kontakte_loeschen();
    break;
    case 'b':
    exit(2);
    cout << endl << "a";
    default:
    cout << "Ungueltige Eingabe!!!";
    break;

    }
    }

    return 0;

    operations.h
    #ifndef operationsH
    #define operationsH

    #include <iostream>
    #include <string>
    #include <fstream>
    using namespace std;

    class operations
    {
    public:

    int PKontakt_speichern()
    { class PKontakt pkontakt;//Adresse adresse

    ofstream out ("Private_Kontakte.dat", ios_base::app);

    cout << "\t NEUEn Privaten Kontakt SPEICHERN";
    cout << endl << endl;

    if(!out)
    {
    cout << "Datei kann nicht geoeffnet werden!" << endl;
    return 1;
    }

    cout << "Geben Sie den Kontakt wie gefolgt ein!" << endl;
    ////////////////////
    ////////////////////
    cout << "Name : ";
    cin >> pkontakt.name;
    if(pkontakt.name == "b")
    {
    return -1;
    }
    out << pkontakt.name << " ";
    ////////////////////
    ////////////////////
    cout << "Vorname : ";
    cin >> pkontakt.vorname;
    if(pkontakt.vorname == "b")
    {
    return -1;
    }
    out << pkontakt.vorname << " ";
    ////////////////////
    ////////////////////
    cout << "Telefon : ";
    cin >> pkontakt.telefon;
    if(pkontakt.telefon == "b")
    {
    return -1;
    }
    out << pkontakt.telefon << " ";
    ////////////////////
    ////////////////////
    cout << "Strasse : ";
    cin >> pkontakt.strasse;
    if(pkontakt.strasse == "b")
    {
    return -1;
    }
    out << pkontakt.strasse << " ";
    ////////////////////
    ////////////////////
    cout << "Nummer : ";
    cin >> pkontakt.nummer;
    if(pkontakt.nummer == "b")
    {
    return -1;
    }
    out << pkontakt.nummer << " ";
    ////////////////////
    ////////////////////
    cout << "Postleitzahl: ";
    cin >> pkontakt.plz;
    if(pkontakt.plz == "b")
    {
    return -1;
    }
    out << pkontakt.plz << " ";
    ////////////////////
    ////////////////////
    cout << "Ort : ";
    cin >> pkontakt.ort;
    if(pkontakt.ort == "b")
    {
    return -1;
    }
    out << pkontakt.ort << " ";
    ////////////////////
    ////////////////////
    cout << "E-Mail : ";
    cin >> pkontakt.e_mail;
    if(pkontakt.e_mail == "b")
    {
    return -1;
    }
    out << pkontakt.e_mail << " ";
    ////////////////////
    ////////////////////
    cout << "Geburtsdatum : ";
    cin >> pkontakt.gebdatum;
    if(pkontakt.gebdatum == "b")
    {
    return -1;
    }
    out << pkontakt.gebdatum << " ";
    ////////////////////
    ////////////////////
    cout << "Geschlecht : ";
    cin >> pkontakt.geschlecht;
    if(pkontakt.geschlecht == "b")
    {
    return -1;
    }
    out << pkontakt.geschlecht << " ";
    ////////////////////
    ////////////////////
    cout << "Vorlieben : ";
    cin >> pkontakt.vorlieben;
    if(pkontakt.vorlieben == "b")
    {
    return -1;
    }
    out << pkontakt.vorlieben << endl;

    cout << endl;
    out.close();

    return 0;
    }
    int DKontakt_speichern()
    { class DKontakt dkontakt;//Adresse adresse

    ofstream out ("Dienstliche_Kontakte.dat", ios_base::app);

    cout << "\t NEUEn dienstlichen Kontakt SPEICHERN";
    cout << endl << endl;

    if(!out)
    {
    cout << "Datei kann nicht geoeffnet werden!" << endl;
    return 1;
    }

    cout << "Geben Sie den Kontakt wie gefolgt ein!" << endl;
    ////////////////////
    ////////////////////
    cout << "Name : ";
    cin >> dkontakt.name;
    if(dkontakt.name == "b")
    {
    return -1;
    }
    out << dkontakt.name << " ";
    ////////////////////
    ////////////////////
    cout << "Vorname : ";
    cin >> dkontakt.vorname;
    if(dkontakt.vorname == "b")
    {
    return -1;
    }
    out << dkontakt.vorname << " ";
    ////////////////////
    ////////////////////
    cout << "Telefon : ";
    cin >> dkontakt.telefon;
    if(dkontakt.telefon == "b")
    {
    return -1;
    }
    out << dkontakt.telefon << " ";
    ////////////////////
    ////////////////////
    cout << "Strasse : ";
    cin >> dkontakt.strasse;
    if(dkontakt.strasse == "b")
    {
    return -1;
    }
    out << dkontakt.strasse << " ";
    ////////////////////
    ////////////////////
    cout << "Nummer : ";
    cin >> dkontakt.nummer;
    if(dkontakt.nummer == "b")
    {
    return -1;
    }
    out << dkontakt.nummer << " ";
    ////////////////////
    ////////////////////
    cout << "Postleitzahl: ";
    cin >> dkontakt.plz;
    if(dkontakt.plz == "b")
    {
    return -1;
    }
    out << dkontakt.plz << " ";
    ////////////////////
    ////////////////////
    cout << "Ort : ";
    cin >> dkontakt.ort;
    if(dkontakt.ort == "b")
    {
    return -1;
    }
    out << dkontakt.ort << " ";
    ////////////////////
    ////////////////////
    cout << "E-Mail : ";
    cin >> dkontakt.e_mail;
    if(dkontakt.e_mail == "b")
    {
    return -1;
    }
    out << dkontakt.e_mail << " ";
    ////////////////////
    ////////////////////
    cout << "Name des Unternehmens : ";
    cin >> dkontakt.unternehmen;
    if(dkontakt.unternehmen == "b")
    {
    return -1;
    }
    out << dkontakt.unternehmen << " ";
    ////////////////////
    ////////////////////
    cout << "Art des Unternehmens : ";
    cin >> dkontakt.art;
    if(dkontakt.art == "b")
    {
    return -1;
    }
    out << dkontakt.art << " ";
    ////////////////////
    ////////////////////
    cout << endl;
    out.close();

    return 0;
    }
    int Kontakt_suchen()
    { class PKontakt pkontakt;
    string suchwort;
    int zaehler = 0;

    cout << "\t Kontakt SUCHEN";
    cout << endl << endl;

    ifstream in ("Private_Kontakte.dat");

    if (!in)
    {
    cout << "Datei kann nicht geoeffnet werden!" << endl;
    return 1;
    }

    cout << "Geben Sie den Suchtext ein: ";
    cin >> suchwort;

    while (!in.eof())
    {
    in >> pkontakt.name;
    in >> pkontakt.vorname;
    in >> pkontakt.telefon;
    in >> pkontakt.strasse;
    in >> pkontakt.nummer;
    in >> pkontakt.plz;
    in >> pkontakt.ort;
    in >> pkontakt.e_mail;
    in >> pkontakt.gebdatum;
    in >> pkontakt.geschlecht;
    in >> pkontakt.vorlieben;

    if (pkontakt.name == suchwort || pkontakt.vorname == suchwort || pkontakt.telefon == suchwort || pkontakt.strasse == suchwort || pkontakt.nummer == suchwort || pkontakt.plz == suchwort || pkontakt.ort == suchwort || pkontakt.e_mail == suchwort || pkontakt.gebdatum == suchwort || pkontakt.geschlecht == suchwort || pkontakt.vorlieben == suchwort)
    {
    zaehler++;

    cout << endl;
    cout << "Nachname + Vorname : " << pkontakt.name << " ";
    cout << pkontakt.vorname << endl;
    cout << "Telefon : " << pkontakt.telefon << endl;
    cout << "Strasse + Hausnummer: " << pkontakt.strasse << " ";
    cout << pkontakt.nummer << endl;
    cout << "PLZ + Ort : " << pkontakt.plz << " ";
    cout << pkontakt.ort << endl;
    cout << "E-Mail : " << pkontakt.e_mail << endl;
    cout << "Homepage : " << pkontakt.gebdatum << endl;
    cout << "Fax : " << pkontakt.geschlecht << endl;
    cout << "Handynummer : " << pkontakt.vorlieben << endl;

    //Der "Weiterblock"
    cout << endl;
    cout << "Druecken Sie 'w' um zur naechsten Adresse oder ins Hauptmenue zu kommen." << endl;
    cout << "Druecken Sie 'b' um direkt ins Hauptmenue zu kommen." << endl;
    string w_o_b_answer;
    cout << "Ihre Antwort: ";
    cin >> w_o_b_answer;

    if (w_o_b_answer == "b")
    {
    return -1;
    }

    }

    }

    cout << endl;
    if (zaehler == 1)
    {
    cout << zaehler << " Kontakt gefunden." << endl;
    }
    else
    {
    cout << zaehler << " Kontakt gefunden." << endl;
    }

    in.close();
    return 0;
    }

    int Kontakte_loeschen()
    {
    char entscheidung;

    cout << "\t ALLE kontakte LOESCHEN";
    cout << endl << endl;

    cout << "Moechten Sie alle Adressen loeschen? j/n";
    cout << endl << endl;
    cout << "Ihre Eingabe: ";
    cin >> entscheidung;

    cout << endl << endl;
    if(entscheidung == 'n')
    {
    cout << "kontakte wurden nicht geloescht!";
    return -1;
    }

    cout << "Sind Sie ganz sicher? j/n";
    cout << endl << endl;
    cout << "Ihre Eingabe: ";
    cin >> entscheidung;

    cout << endl << endl;
    if(entscheidung == 'n')
    {
    cout << "kontakte wurden nicht geloescht!";
    return -1;
    }

    ofstream out ("Private_Kontakte.dat", ios_base::out);
    //ofstream out ("Dienstliche_Kontakte.dat",, ios_base::out);

    cout << "Daten wurden geloescht!";

    out.close();

    return 0;
    }

    }; // Ende der Klasse

    #endif

    Pkontak.h (das selbe bei DKontakt.h)
    #include <iostream>
    #include <string>
    #include <fstream>

    class PKontakt
    {
    public:
    string name;
    string vorname;
    string telefon;
    string strasse;
    string nummer;
    string plz;
    string ort;
    string e_mail;
    string gebdatum;
    string geschlecht;
    string vorlieben;
    };
    #endif



  • was haben termine ünerhaupt mit einem adressbuch zu tun?

    aber allgemein... denk mal ein wenig drüber nach

    termine gehören zu einer person
    jede person hat eine liste von terminen

    termine bestehen aus:
    -einem terminzeitpunkt/datum
    -einem vorwarnzeitpunkt/datum
    -einer dauer

    alles was du tun musst ist bei jeder person eine liste von terminen zu speichern



  • Hi! Danke erstmal für die schnelle Antwort.

    Hmm eine Liste, aber wie kann ich die einbinden?
    Kannst du mir da kurz codemässig auf die sprünge helfen?
    Sitz auf der Leitung.

    Ich weiss nciht wie ich die in die Funktion Kontakt hinzufügen
    einbinden soll, das man dann da in einem Untermenu den Termin einträgt.

    p.s. Termine müssen leider mit rein 🙂



  • erzähl uns doch erstmal worums geht
    addressbuch, kontakliste, termine

    das kann alles sein



  • Versuch doch mal mit Verkettete Listen zu speichern.



  • Hi!

    Okay, also:
    Ein Adressbuch (Termin und Adressbuch), 2 Arten von Kontakten, private und dienstliche, Beide Arten haben folgende Daten gespeichert:
    Name,Vorname,Anschrift,email,tele. Bei dienstlichen zusätzlich Name des Unternehmens, Art des Unternehmens und bei Privaten zusätzlich geburtsdatum der Person, Geschlecht, besondere Vorlieben.

    Zu jedem Kontakt kommen Termine hinzu, die beinhalten noch Datum, Uhrzeit, Anschrift, Anlass.

    -Nun soll man Kontakte anlegen können (Das hab ich schon jedoch in 2 Dateien
    Einmal Privat_Kontakte.dat und einmal Dienstliche_Kontakte.dat
    -Dann einen Termin zu einem Kontakt anlegen (weis ich nicht wie)
    -Löschen eines Termins oder Kontakts (hab ich auch nicht)
    -Suchen eines Kontaktes oder Termins (Hab ich aber nur für Kontakte)
    -Auflisten aller Kontakte mit Terminen (Weis ich auch nicht wegen den Terminen)

    Das solls können. Ich hab halt nun PKontakte.h und DKontakte.h mit Attributen.
    Zusätzlich hab ich nun eine Termin.h geschrieben mit den oben genannten Attributen die ein Termin haben soll.
    Nun weis ich nicht wie ich die Termin.h so (vielleicht) reinschachteln soll,
    das dies mit den KOntakten zusammenhängt.

    Hoffe ich konnts gut erklären.

    Also Termine.h sieht so aus:

    #ifndef TermineH
    #define TermineH

    #include <iostream>
    #include <string>
    #include <fstream>

    class Termine
    {
    public:
    string Datum;
    string Uhrzeit;
    string Strasse;
    string Hausmummer;
    string PLZ;
    string Ort;
    string Anlass;
    };
    #endif


Anmelden zum Antworten