cours work (just have a look)

hi everyone
i have a courswork and i start to write this
Data Structure
Create a data structure suitable for storing data for a list of appointments. Each appointment record should include the following fields:

Field Field data type
• Person name string
• Appointment descriptions (e.g. Lunch) string
• Appointment Date structure
• day integer
• month integer
• year integer
• Time string

(use 24 hour clock (e.g. 11:00, 13:40, 15:30, etc.));

Allow for up to 30 appointments.

The program should be menu driven and allow the user to interactively select and perform the following tasks:
1. Add details of one or more appointments to the appointment structure;
a) Add validation to step1
• Check if there is enough room in the structure to accommodate the appointment record(s) you want to add;
• Check if there is an appointment on the same date and time.
(Obviously you can have several appointments on the same day at different
times, and for the same time on different days.)
• In case of failure of any of the above checks the program should print an appropriate warning message and not proceed with the operation.
2. Edit an appointment: change the person name or the appointment description but not the Time or Date;
3. Delete an appointment;
• Search for the appointment in appointments structure using the appointment date and time;
• Delete the appointment by shifting the records following the record to be deleted upwards;
4. Display appointments details:
a) For a certain date;
b) All appointments
Appointments should be displayed under the following header:

Person Appointment Appointment Appointment
Name Description Date Time

5. Write appointments list records to a file;
• Store each appointment record fields as follows:

person name
appointment description
appointment time
day month year

Each line should be followed by a new line character (i.e. use endl or '\n' )

6. Read appointments list records from a file;
• Data must be read in the same order it was written.
• Note: you need to read a character left in the input buffer after reading each record (use: infile.get( ) ) so that data is read properly.
7. Quit program.

Your program should be modular by developing separate functions for the above tasks. Comment your program. Each function should have at least one comment saying what the function does



and i start like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <iostream>
#include<iomanip>
#include <cstdlib>
#include <string>
  using namespace std;
//declare structure types 
	struct AppointmenRecord{ 
		string name;
		string description;
		double date;
		double time;
	       };

const int listSize = 30;    //number of records in array
int currentSize = 0;
//declare a list of records.
	AppointmenRecord AppointmenList[listSize];     //global array of records

// Functions prototypes.  
void addAppointmenRecords( );
void displayAllRecords( );
void editAppointmen( );
void displayMenu(int &option);


 
void main( )
{
    int option; 
    bool endOfSession = false;
//get user action choice
   while (!endOfSession)
   {	
       displayMenu(option);

switch (option)
       {   
         case 1: addAppointmenRecords( );
                	 break;
         case 2: displayAllRecords( );
                	 break;
		 //case 3: editAppointmenRecords( );
                	 break;
         case 4: system("cls");
                 	 cout<<"\nEND OF SESSION\n\n";
                	 endOfSession = true;
                	 break;
         default: cout<<endl<<"Wrong option number!! Try again\n";
       }
   }
}

void displayMenu(int &option)
{ // display menu options and choose one 

     system("cls");        //clear screen
                 
    cout<<endl<<endl;
    cout<<"\t    * APPOINTMENTS DATA MENU *"<<endl<<endl;
    cout<<"\t  1. Add An Appointmen record(s)"<<endl;
    cout<<"\t  2. Display All Appointmens records"<<endl;
    cout<<"\t  3. Edit An Appointmen record(s)"<<endl;
    cout<<"\t  4. End Session"<<endl;
    cout<<endl<<setw(28)<<"Enter option number: ";

    cin>>option;
    cin.get();
}

 
void addAppointmenRecords( )
{  
        int number, i;

system("cls");         //clear screen

	cout<<"\nHow many Appointmen you wish to add? ";
	cin>>number;
	cin.get();                         //read newline character left in the buffer

	if( (number + currentSize ) <= listSize)                   //There is still room in the array	
	      for( i = 1; i<=number; i++)
                         {
			cout<<"\nEnter Person name: ";
			getline(cin, AppointmenList[currentSize].name);
			cout<<"Enter Appointmen Descriptions: ";
			cin>>AppointmenList[currentSize].description;
			cout<<"Enter Appointmen date: ";
            cin>>AppointmenList[currentSize].date;
			cout<<"Enter Appointmen time: ";
            cin>>AppointmenList[currentSize].date;
			cout<<endl;

	  		 cin.get();          //read newline character left in the buffer
			currentSize += 1;
		}
	else
cout<<"Overflow!!!! Appointmen List is full"<<endl;
         

cout<<"\nPress any key to continue"<<endl;
cin.get();     //read a character 
}


void displayHeading( )
{      
           cout<<setiosflags(ios::left);                //left justify output
			cout<<endl<<setw(20)<<"Name"
               <<setw(20)<< "Descriptions"
               <<setw(12)<<"Date"
			   <<setw(15)<<"Time"<<endl;
}

 
void displayAllRecords( )
{   /* print the data from the array of records under a suitable header*/
    
      int index;

       system("cls");
       displayHeading();
       cout<<setiosflags(ios::left);                //left justify output

       for (index = 0; index < currentSize; index++)
        {
	cout<<setw(20)<<AppointmenList[index].name;
	cout<<setw(15)<<AppointmenList[index].description;
	cout<<setw(12)<<AppointmenList[index].date;
	cout<<setw(12)<<AppointmenList[index].time<<endl;
        }
   //give the user a chance to read the output data
  	cout<<endl<<"Press any character to continue  ";
	cin.get();          //read entered character      
}


am i on the write way????
if i am doing wrong can yous tell me your recommendation??/
thanks...
looks fine to me..functionality is distributed across functions.

a couple of things which i found missing:

Check if there is an appointment on the same date and time.
Write appointments list records to a file;


addAppointmenRecords can have a function to add the details to file.




Topic archived. No new replies allowed.