Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <windows.h>
- using namespace std;
- const int Size=20;
- class Manager
- {
- //Private Start
- private:
- struct AppointmentData //Structured Array Start
- {
- string StudentName;
- string ID;
- string PhoneContact;
- string Appointment_Time;
- } Appointment[Size]; //Structured Array End
- //Private End
- //Public Start
- public:
- AppointmentType(); //Constructor
- void SetAppointment( string , string, string, string);
- void printAppointment()const;//Access
- string GetInformation()const;
- string GetInformation1()const;
- string GetInformation2()const;
- string GetInformation3()const;
- //Public End
- };
- int main()
- {
- //Object
- Manager Appointments;
- ifstream readFile;
- ofstream WriteFile;
- string Stu, ID, PC, App_Time;
- char Operator=' ';
- do
- {
- cout<<"\n-------------------------";
- cout<<"\n (1)Add a New Appointment:"
- <<"\n (2)Update/Edit an Appointment:"
- <<"\n (3)Display All Appointments:"
- <<"\n (4)Search for an Appointment(by ID#):"
- <<"\n (5)Delete an Appointment :"
- <<"\n (6)Help Guide :"
- <<"\n (x)Exit program Press:"
- <<"\n-------------------------\n Enter Your Choice:";
- cin>>Operator;
- switch (Operator)
- {
- case '1':
- for(int i =0; i < Size ; i++)
- {
- WriteFile.open("Appointments2.txt",ios::app|ios::out);
- cout <<"\n Enter Name: ";
- cin.get();
- getline(cin, Stu);
- cout<<"\n Enter ID: ";
- getline(cin, ID);
- cout<<"\n Enter Phone Contact: ";
- getline(cin, PC);
- cout<<"\n Enter Appointment Time: ";
- getline(cin, App_Time);
- Appointments.SetAppointment(Stu,ID,PC,App_Time);
- WriteFile<<Stu<<endl<<ID<<endl<<PC<<endl<<App_Time;
- break;
- }
- break;
- case '3':
- Appointments.printAppointment();
- break;
- case 'x':
- cout << "\n The program has been exited";
- break;
- }
- }
- while(Operator!='x');
- WriteFile.close();
- }
- //Constructor Start
- Manager::AppointmentType() // Constructor
- {
- for(int i=0; i<Size; i++)
- {
- Appointment[i].StudentName="";
- Appointment[i].ID="";
- Appointment[i].PhoneContact="";
- Appointment[i].Appointment_Time="";
- }
- }
- //Constructor End
- // Mutator Start
- void Manager::SetAppointment(string Stu,string ID,string PC,string App_Time) //SetAppointments Start
- {
- ifstream readFile;
- readFile.open("Appointments2.txt",ios::in);
- for(int i = 0; i< Size; i++)
- {
- readFile>>Stu>>ID>>PC>>App_Time;
- for (int i =0; i <Size; i++)
- {
- if(Appointment[i].StudentName == "")
- {
- Appointment[i].StudentName=Stu;
- Appointment[i].ID =ID;
- Appointment[i].PhoneContact =PC;
- Appointment[i].Appointment_Time=App_Time;
- break;
- }
- }
- } //Set Appointments End
- readFile.close();
- }
- //MutatorEnd
- void Manager::printAppointment()const //Print Info Start
- {
- for (int i =0; i <Size; i++)
- {
- if(Appointment[i].StudentName!="")
- {
- cout<<"\n Student Name: "<<Appointment[i].StudentName
- <<"\n Student ID: "<<Appointment[i].ID
- <<"\n Student PhoneContact:"<<Appointment[i].PhoneContact
- <<"\n Student AppointmentTime#: "<<Appointment[i].Appointment_Time<<endl<<endl;
- }
- }
- } //Print Info End
- //Access End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement