import javax.microedition.lcdui.*; import javax.microedition.midlet.*; /** * @author kiriman */ public class Plan extends MIDlet implements CommandListener { public Form f; public TextField tf, tf1, tf3; public String sss, doouuuu, igomgmhnmhmkhm, vr, vr1, sdatmm; public Command ok = new Command("OK", Command.OK, 0); public Command cancel = new Command("OK", Command.OK, 0); public Display di; public double pl1, ss, do1, plan, zd; public int s4, sm, do4, dom, r4, rm, zdg, zdk, s, do2, r, rd; public Plan() { di = Display.getDisplay(this); } public void startApp() { f = new Form("Кондуктор"); tf = new TextField("Работаю с:", sss, 1000, TextField.DECIMAL); tf1 = new TextField("До:", doouuuu, 1000, TextField.DECIMAL); tf3 = new TextField("План:", igomgmhnmhmkhm, 1000, TextField.NUMERIC); f.append(tf); f.append(tf1); f.append(tf3); f.addCommand(ok); f.setCommandListener(this); di.setCurrent(f); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable d) { if (c == ok) { sss = tf.getString(); doouuuu = tf1.getString(); igomgmhnmhmkhm = tf3.getString(); ss = Double.parseDouble(sss); do1 = Double.parseDouble(doouuuu); plan = Double.parseDouble(igomgmhnmhmkhm); Joooo(); f.deleteAll(); f.removeCommand(ok); f.addCommand(cancel); f.append("Время работы:\n" + r4 + "." + rm + "\nСдать в кассу:\n" + zdg + "." + zdk); } if (c == cancel) { startApp(); } } public void Joooo() { vr = String.valueOf(ss); int i = vr.indexOf('.'); vr = vr.substring(0, i); vr1 = String.valueOf(do1); i = vr1.indexOf('.'); vr1 = vr1.substring(0, i); s4 = Integer.parseInt(vr); do4 = Integer.parseInt(vr1); vr = String.valueOf(ss); i = vr.indexOf('.'); vr = vr.substring(i + 1, vr.length()); if (vr.length() < 2) { vr = vr + "0"; } vr1 = String.valueOf(do1); i = vr1.indexOf('.'); vr1 = vr1.substring(i + 1, vr1.length()); if (vr1.length() < 2) { vr1 = vr1 + "0"; } sm = Integer.parseInt(vr); dom = Integer.parseInt(vr1); s = (s4 * 60) + sm; do2 = (do4 * 60) + dom; if (do2 < s) { rd = (24 * 60) - s; r = rd + do2; bugaga(); } else { r = do2 - s; bugaga(); } return; } public void bugaga() { plan = plan * 100 / 60; zd = r + plan; r4 = r / 60; rm = r - (r4 * 60); zdg = (int) ((zd / 100d) + 0.1d); zdk = (int) (zd - (zdg * 100)); return; } }