Пример #1
0
    private ShiftTable GenerateSchedule(ShiftTable OptionsTable, ShiftTable schedule)
    {
        ShiftTable weeklyShifts = new ShiftTable(this.weeklyShifts);

        GenerateScheduleRandomPass(OptionsTable, weeklyShifts, schedule);

        bool done = false;
        bool shiftAdded = false;

        int optionsNum = OptionsTable.tableSize();

        while (!done)
        {
            shiftAdded = false;
            for (int i = 0; i < optionsNum; i++)
            {
                Shift option = OptionsTable.getShiftFromTable(i);
                if (weeklyShifts.shiftExists(option.getDay(), option.getBegin_Time(), option.getEnd_Time()))
                {
                    if (schedule.optionLegal(option))
                    {
                        schedule.AddShift(option);
                        OptionsTable.RemoveShift(option);
                        optionsNum--;
                        weeklyShifts.RemoveShift(option.getDay(), option.getBegin_Time(), option.getEnd_Time());

                        shiftAdded = true;
                        break;
                    }

                }
            } // for ()
            if (shiftAdded == false)
            {
                done = true;
            }

        }
        return schedule;
    }
Пример #2
0
 public void OptionLegalTest2_differentID()
 {
     //arrange
         ShiftTable schedule = new ShiftTable();
         Shift shift = new Shift("123456789", "Polishuk", "Sunday", "7", "15", "Sion", "", "");
         schedule.AddShift(shift);
         Shift option = new Shift("111222333", "Polishuk", "Sunday", "7", "15", "Sion", "", "");
         //act
         bool result = schedule.optionLegal(option);
         //assert
         Assert.AreEqual(result, true, "OptionLegalTest2_differentID error: the IDs are not similar");
 }
Пример #3
0
    private void GenerateScheduleRandomPass(ShiftTable OptionsTable, ShiftTable weeklyShifts, ShiftTable schedule)
    {
        Random rnd = new Random();
        int optionsNum = OptionsTable.tableSize();
        while (optionsNum > 0)
        {
            int i = rnd.Next(0, optionsNum);
            Shift option = OptionsTable.getShiftFromTable(i);

            if (weeklyShifts.shiftExists(option.getDay(), option.getBegin_Time(), option.getEnd_Time()))
            {
                if (schedule.optionLegal(option))
                {
                    schedule.AddShift(option);
                    weeklyShifts.RemoveShift(option.getDay(), option.getBegin_Time(), option.getEnd_Time());
                }
            }
            OptionsTable.RemoveShift(option);
            optionsNum--;
        } //while (optionsNum > 0)...
    }
Пример #4
0
 public void OptionLegalNegativeTest_sameHour()
 {
     //arrange
         ShiftTable schedule = new ShiftTable();
         Shift shift = new Shift("123456789", "Polishuk", "Sunday", "7", "15", "Sion", "", "");
         schedule.AddShift(shift);
         Shift option = new Shift("123456789", "Polishuk", "Sunday", "7", "15", "Sion", "", "");
         //act
         bool result = schedule.optionLegal(option);
         //assert
         Assert.AreEqual(result, false, "OptionLegalNegativeTest_sameHour error: the hours are similar");
 }