Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello
i am working on a timetable generating program .now i have to check for clashes before the timetable is generated. i struggle with c# anyone to help. i am lost on what to do next

What I have tried:

private void btnAdd_Click(object sender, EventArgs e)
       {

           bool isClashing = CheckClash();

           if (isClashing == false)
           {
               saveTimetable();

           }

           else
           {
               MessageBox.Show("The timeslot chosen is allready occupied!!");
           }
private Boolean CheckClash()
       {

           return false;
       }
Posted
Updated 3-May-19 0:35am
Comments
BillWoodruff 3-May-19 8:47am    
Start by defining what you mean by "clash." Is any "overlap" allowed ?

You need to keep a list of timetable objects, each with its start time and duration. Then when the user tries to add a new item you need to compare its time requirements with the existing list. There may also be other constraints that you need to compare against.
 
Share this answer
 
You need to iterate over all your items and check for each one, if it clashes with another one.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900