Project creation, basics

This commit is contained in:
2023-03-12 12:32:26 +01:00
Unverified
commit 95364c8a31
68 changed files with 3517 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TimetableDesigner.Core
{
[Serializable]
public class TimetableTemplate
{
#region FIELDS
private List<TimetableDay> _days;
private List<TimetableSlot> _slots;
#endregion
#region PROPERTIES
public IEnumerable<TimetableDay> Days => _days;
public IEnumerable<TimetableSlot> Slots => _slots;
#endregion
#region CONSTRUCTORS
public TimetableTemplate()
{
_days = new List<TimetableDay>();
_slots = new List<TimetableSlot>();
}
#endregion
#region PUBLIC METHODS
public void AddDay(TimetableDay name)
{
_days.Add(name);
}
public bool RemoveDay(TimetableDay day)
{
return _days.Remove(day);
}
public void AddSlot(TimetableSlot slot)
{
int i = 0;
if (_slots.Count > 0)
{
bool done = false;
while (i < _slots.Count && !done)
{
switch (slot.CheckCollision(_slots[i]))
{
case TimetableSlotsCollision.CheckedSlotBefore: i++; break;
case TimetableSlotsCollision.CheckedSlotAfter: done ^= true; break;
default: throw new ArgumentException("Slot collide with another slot");
}
}
}
_slots.Insert(i, slot);
}
public bool RemoveSlot(TimetableSlot slot)
{
return _slots.Remove(slot);
}
#endregion
}
}