point.java
来自「Program helping you to remember the rout」· Java 代码 · 共 37 行
JAVA
37 行
public class Point {
String description;
int time;
int direction;
int tripId;
int id;
byte[] pack() {
byte[] desc = Converter.packString(description);
byte[] buf = new byte[desc.length + 9];
Converter.packInt(buf, 0, tripId);
Converter.packInt(buf, 4, time);
buf[8] = (byte)direction;
System.arraycopy(desc, 0, buf, 9, desc.length);
return buf;
}
void unpack(byte[] buf) {
tripId = Converter.unpackInt(buf, 0);
time = Converter.unpackInt(buf, 4);
direction = buf[8];
description = Converter.unpackString(buf, 9, buf.length - 9);
}
Point(int id, byte[] buf) {
this.id = id;
unpack(buf);
}
Point(int tripId, int direction, String description, int time) {
this.tripId = tripId;
this.direction = direction;
this.description = description;
this.time = time;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?