Homework 3

Washing Machine

Step of washing

  1. Get the input of the human.
  2. Add the water.
  3. Begin to wash
  4. Drain the water
  5. Add the water.
  6. Begin to wash
  7. Drain the water
  8. Halt

Pseudocode of washing

Water_in_switch(open)
Water_out_switch(close)
If(get_water_volume()!=Target_volume and time_counter() > set_time)
    {
Water_in_switch(close)
Water_out_switch(open)
halt(failure)
}
Water_in_switch(close)
While(washing_time_counter>0)
 {
    while(time_counter()<loop_time){
    Motor_run(left);
    While(time_counter()<next_step_time)
    {
}
Motor_run(right)
While(time_counter()<next_step_time)
    {
}}
While(get_water_volumn()!=0)
Water_out_switch(open)
}
Halt(success)

Module:
Wait(time)
{
    Previous=time_counter()
    While(time_counter()<=previous+time)
    {
    }
}
注水(volume,timeout)
{
    If(get_water_volume()!=volume and time_counter() > timeout)
    {
Water_in_switch(close)
Water_out_switch(open)
halt(failure)
}
}
排水()
{
While(get_water_volumn()!=0)
Water_out_switch(open)
}

The difference between Normal washing and Quick washing

The difference is the repeat time of whole washing step and washing time. Normal washing will repeat for 2 or 3 times, and quick washing will just repeat 1 or 2 times. And the time it cost will be different.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值