import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import java.util.*; public class SlideShow extends MIDlet implements CommandListener { public Canv canv; public Display display; public Form form; public Command next; public Command back; public Image image; private int max, number; private Graphics g; private String[] str; public SlideShow() { canv=new Canv(this); } public void startApp() { form = new Form(null); image=Image.createImage(form.getWidth(), form.getHeight()); g=image.getGraphics(); str=new String[5]; int day=Calendar.getInstance().get(Calendar.DAY_OF_WEEK); if (day==2){ ponedelnik(); number=1;} if (day==3){vtornik(); number=2;} if (day==4) {sreda(); number=3;} if (day==5){ chetverg(); number=4;} if (day==6){ patnitsa(); number=5;} max = 5; display = Display.getDisplay(this); next = new Command("Туда", Command.OK, 1); back = new Command("Сюда", Command.BACK, 1); canv.addCommand(next); canv.addCommand(back); setImage(str); canv.setCommandListener(this); display.setCurrent(canv); } public void pauseApp() { } public void destroyApp(boolean unconditional) { notifyDestroyed(); } public void commandAction(Command c, Displayable d) { if (c==next&&number<=max) { number++; if (number>max) number = 1; } if (c==back&&number>=1) { number--; if (number<1) number=max; } form.delete(0); if(number==1) ponedelnik(); if(number==2) vtornik(); if(number==3) sreda(); if(number==4) chetverg(); if(number==5) patnitsa(); setImage(str); } public void setImage(String[] s) { g.setColor(0,0,0); g.fillRect(0, 0, image.getWidth(), image.getHeight()); g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE)); g.setColor(0,0,255); g.drawString(s[0], 40, 10, Graphics.LEFT | Graphics.TOP); g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_ITALIC, Font.SIZE_MEDIUM)); g.setColor(255, 255, 0); g.drawString(s[1],5,60, Graphics.LEFT | Graphics.TOP); g.drawString(s[2],5,90, Graphics.LEFT | Graphics.TOP); g.drawString(s[3],5,120, Graphics.LEFT | Graphics.TOP); g.drawString(s[4],5,150, Graphics.LEFT | Graphics.TOP); form.append(image); } public void ponedelnik() { str[0]="Понедельник"; str[1]="Информат.("; str[2]="Англ. язык(52)"; str[3]="Электротехн.(301)"; str[4]="(2 нед.)Электротехн.(301)"; } public void vtornik() { str[0]="Вторник"; str[1]="Черчение(1 гр.)(62)"; str[2]="Укр. язык(42)"; str[3]="Электротехн.(301)"; str[4]="Математика(72)"; } public void sreda() { str[0]="Среда"; str[1]="История Украины(81)"; str[2]="Физ-ра"; str[3]="Биология(74)"; str[4]="Черчение(2 гр.)(62)"; } public void chetverg() { str[0]="Четверг"; str[1]="Экономика(210)"; str[2]="Физика(73)"; str[3]="Культурология(80)"; str[4]="(2 нед.)Специализация(301)"; } public void patnitsa() { str[0]="Пятница"; str[1]="Горное дело(316)"; str[2]="Электротехн.(301)"; str[3]=" "; str[4]=" "; } }