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

📄 trip.java

📁 Program helping you to remember the route. It cab be route from conference room to coffee-room, it
💻 JAVA
字号:
public class Trip { 
    String  description;
    Point[] points;
    int     time;
    int     id;

    byte[] pack() { 
        byte[] desc = Converter.packString(description);
        byte[] buf = new byte[desc.length + 8];
        Converter.packInt(buf, 4, time);
        System.arraycopy(desc, 0, buf, 8, desc.length);
        return buf;
    }

    void unpack(byte[] buf) {        
        time = Converter.unpackInt(buf, 4);
        description = Converter.unpackString(buf, 8, buf.length - 8);
    }

    Trip(int id, byte[] buf) { 
        this.id = id;
        unpack(buf);
    }

    int duration() { 
        return points.length > 0 ? points[points.length-1].time - time : 0;
    }

    Trip(String description, int time) { 
        this.description = description;
        this.time = time;
        points = new Point[0];
    }
}

⌨️ 快捷键说明

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