编程题:实现一个 LazyMan

题目 实现一个 LazyMan,可以按照以下方式调用: LazyMan('Tony'); // Hi I am Tony LazyMan('Tony').sleep(10).eat('lunch'); // Hi I am Tony // 等待了10秒... // I am eating lunch LazyMan('Tony').eat('lunch').sleep(10).eat('dinner'); // Hi I am Tony // I am eating lunch // 等待了10秒... // I am eating diner LazyMan('Tony') .eat('lunch') .eat('dinner') .sleepFirst(5) .sleep(10) .eat('junk food'); // Hi I am Tony // 等待了5秒... // I am eating lunch // I am eating dinner // 等待了10秒... // I am eating junk food 思路 总共需要实现三个函数:一个同步的 eat,两个异步的 sleep、sleepFirst。...

2022-05-30