📄 main.java
字号:
import java.util.Date;class Clock { private Date clockTime = new Date(96, 0, 1, 0, 0, 0); private static String fixWidth(int num) { if (num == 0) return "00"; if (num < 10) return ("0" + num); return (Integer.toString(num, 10)); } private void updateLCD(boolean blink) { // could be replaced by more fancy GUI System.out.println(fixWidth(clockTime.getHours()) + ":" + fixWidth(clockTime.getMinutes()) + ":" + fixWidth(clockTime.getSeconds())); if (blink) updateLCD(false); // recurse once } public void set(int hh, int mm, int ss) { clockTime.setHours(hh); clockTime.setMinutes(mm); clockTime.setSeconds(ss); updateLCD(false); // do not blink after setting } public void display(boolean blink) { updateLCD(blink); }}class Main { public static void main(String[] args) { if (args.length != 3) { System.err.println("Usage: java Main <hh> <mm> <ss>"); System.exit(-1); } int hours = Integer.parseInt(args[0]); int mins = Integer.parseInt(args[1]); int secs = Integer.parseInt(args[2]); Clock c = new Clock(); c.display(true); // blink c.set(hours, mins, secs); // ... }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -