I need to have an idea to write a part of a program I am supposed to do.
This part is meant to be an agenda were we can schedule something and check what conflicts we have when making a new appointment.
I have though of using some kind of structures, but I guess I am complicating the whole thing.
I was thinking of having a struct for the year, a struct for the month and a new struct for the day. Then, the year was having the month structure and the month was having the day structure. But I feel that this can be made more simpler, I just can’t get any better ideas.
How can I make this more simpler?
I just need to make something to store a new appointment on a day and hours and something that it cannot have two appointments for the same time.
Any help, I would appreciate.
enum DiaSemana { Domingo, Segunda, Terca, Quarta, Quinta, Sexta, Sabado };
struct Dia {
int dia;
int semana;
char* horas[24][60];
};
struct Meses {
int mes;
char* nome[11];
struct Dia dia;
};
struct Ano {
int ano;
tipoAno tipo;
struct Meses jan;
struct Meses fev;
struct Meses mar;
struct Meses abr;
struct Meses mai;
struct Meses jun;
struct Meses jul;
struct Meses ago;
struct Meses set;
struct Meses out;
struct Meses nov;
struct Meses dez;
};
typedef struct Ano ANO;
typedef ANO *PANO;
int validaBi(int ano) {
if(ano%4==0)
return 0;
else
return 1;
}
When dealing with problem like this, you essentially got to figure what information you want to put into application and what do you want from it.
So what we can see now, we have an event with begginning and ending. Forgive me using a bit of OOP here, but it still applies to C.
Great. However, what is a DateTime? We’re going to need that one too.
Now I’m gonna really miss the “++” part in C++, but still…
Again, forgive me my ignorance in C. So what we’ve created here is the basic concept of our system. As you probably see now, next step would be the
Add(Calendar, Event)function, but it’s now up to you to figure this out.I’m not saying the above solution is the best, the only one, nor complete. I just wanted to give you a hint on a solving problems like this.