⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zeventgenerator.java

📁 ZDrive Driving Warning System
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package zdrive.testing;import zdrive.protocols.*;/** * * @author Mohamed Aly */public class ZEventGenerator extends ZAbstractEvent{    public ZEventGenerator(int event, double velocity_kph, double total_distance,String direction){        this.event = event;        this.velocity_kph = velocity_kph;        this.remaining_distance_m = total_distance;        this.total_distance_m = total_distance;        this.completed = false;        this.direction = direction;    }    public synchronized double getVelocity(){        return this.velocity_kph;    }    public synchronized double getRemainingDistance(){        return this.remaining_distance_m;    }    public synchronized double getTotalDistance(){        return this.total_distance_m;    }     public synchronized int getEvent(){        return this.event;    }     public synchronized String getDirection(){         return this.direction;     }     public synchronized boolean isCompleted(){         return this.completed;     }    @Override    public void run(){        double time_slept_ms = 0.0;        while(true)        {           // System.out.println(remaining_distance_m);            remaining_distance_m = total_distance_m-((time_slept_ms/3600000)*velocity_kph*1000);            try{            sleep(300);            }catch(Exception e){                e.printStackTrace();            }            time_slept_ms+=300;            if((remaining_distance_m*100/total_distance_m)<=3.0)            {                completed = true;                break;            }        }        notifyAllThreads();    }    public void kill(){        this.stop();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -