我如何检查冲突 [英] How do I check for a clash

查看:80
本文介绍了我如何检查冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在制作一个时间表生成程序。现在我必须在生成时间表之前检查冲突。我和c#的任何人都在努力帮忙。我迷失了下一步该做什么



我尝试过:



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;
       }

推荐答案

您需要保留一份时间表对象列表,每个对象都有其开始时间和持续时间。然后,当用户尝试添加新项目时,您需要将其时间要求与现有列表进行比较。您可能还需要比较其他约束。
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.


您需要迭代所有项目并检查每个项目是否与另一个项目发生冲突。
You need to iterate over all your items and check for each one, if it clashes with another one.


这篇关于我如何检查冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆