有没有简单的方法可以将以下条件实现为简单的条件。
usual_work_start = 9:00
usual_work_end = 17:45
lunch_break_start = 12:00
lunch_break_end = 13:00
And if i am doing overtime
ot_break_start = 17:45
ot_break_end = 18:15
And i have to get the break time depending upon my work_start and work_end times.
some examples are listen below
1. if work_start = 9:00 and work_end = 21:00 then break_time should be lunch_break + overtime_break (90mins break).
2. if work_start = 9:00 and work_end = 12:00 then break_time should be 0(didn't take any break).
3. if work_start = 9:00 and work_end = 17:45 then break_time should be only lunch time (60mins).
如此多的测试取决于开始和结束时间。
我已经做过一个,但是它的嵌套很长,如果不是。任何简单的想法都会有很大的帮助。任何语言都可以,但首选语言是javascript或python。
答案 0 :(得分:0)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Camera_Controller : MonoBehaviour
{
public GameObject player;
private Vector3 offset;
// Start is called before the first frame update
void Start()
{
offset = transform.position - player.transform.position;
}
// Update is called once per frame
void LateUpdate()
{
transform.position = player.transform.position + offset;
}
}
答案 1 :(得分:0)
如果办公时间不是固定的并且对于每个人来说都是相同的,则计算休息时间相对于工作所花费的时间,无论开始和结束时间如何都将更加灵活。可以实现为:
if workTime < 3hrs:
breaktime = 0
elseif workTime > 3hrs && workTime < 7hr 45min:
breaktime = 1hr
elseif worktime > 7hr 45min:
breaktime = 1hr 30min