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

📄 vehicle.java

📁 一些JAVA的小程序
💻 JAVA
字号:
import java.awt.*;
import java.util.*;
import java.lang.*;

public class vehicle{


    public vehicle(int xPosition, int yPosition,int angle1){
        x=xPosition;
        y=yPosition;
        angle=angle1;
        stayStation=1;
    }

    public void setMateVehi(vehicle mate){
        mateVehi=mate;
    }

    public void draw(Graphics g){return;}

    public boolean canEnter(){return true;}//check if a vehicle can enter road from a station

    //a train is impossible to hit the other.
    public boolean canHit(){return false;}//check if vehicle would hit another

    public boolean closeToCross(leverage oneleve){return false;}//check if a vehicle is close enough to intersection

    public boolean passedCross(leverage oneleve){return true;}//check if a vehicle has passed a intersection

    public void setPosition(int x1, int y1){
         x=x1;
         y=y1;
    }

    public void move(){return;}


//make it interface
    public int randomNum(){
        Random number=new Random();
        return (int) Math.abs(Math.floor(number.nextInt()));
    }

    public boolean canStay(){
        return (randomNum()%2)==0;
    }

    public void stayStation(){
        stayStation=randomNum()%50;
    }

    final static int centerX=275;
    final static int centerY=290;

    protected int x;
    protected int y;
    protected int angle; //value of 0 to 359
    protected int stayStation; //value of 0 to 14
    protected int safeSecond; //when stop because of possibility of hitting, start after the mateVehi started.
    protected vehicle mateVehi;

}

⌨️ 快捷键说明

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