Obliczenia brydżowe (Java ME)
Jacek Kowalski
2012-08-07 e757087c400ef18b41ca09b07483d66c61f82309
src/brydz/BrydzForm.java
@@ -4,6 +4,7 @@
public class BrydzForm extends Form implements CommandListener, ItemStateListener {
    protected BrydzMIDlet midlet;
    protected BrydzMenu menu = null;
    
    protected TextField kontraktField;
    protected ChoiceGroup kontraktChoice;
@@ -33,8 +34,10 @@
        this.kontraChoice.append("rektr.", null);
        
        this.partiaChoice = new ChoiceGroup(null, ChoiceGroup.EXCLUSIVE);
        this.partiaChoice.append("przed", null);
        this.partiaChoice.append("po", null);
        this.partiaChoice.append("przed / przed", null);
        this.partiaChoice.append("przed / po", null);
        this.partiaChoice.append("po / przed", null);
        this.partiaChoice.append("po / po", null);
        
        this.punktyField = new TextField("PC:", null, 2, TextField.NUMERIC);
        this.lewyField = new TextField("Lew:", null, 2, TextField.NUMERIC);
@@ -49,14 +52,15 @@
        this.append(this.lewyField);
        this.append(this.resultText);
        
        setItemStateListener(this);
        setCommandListener(this);
        addCommand(new Command("Wyczyść", Command.OK, 1));
        addCommand(new Command("Wyjście", Command.EXIT, 1));
        this.addCommand(new Command("Wyczyść", Command.BACK, 1));
        this.addCommand(new Command("Menu", Command.OK, 1));
        this.setItemStateListener(this);
        this.setCommandListener(this);
    }
    
    public void commandAction(Command command, Displayable displayable) {
        if (command.getCommandType() == Command.OK) {
        if (command.getCommandType() == Command.BACK) {
            this.kontraktField.setString(null);
            this.kontraktChoice.setSelectedIndex(0, true);
            this.kontraChoice.setSelectedIndex(0, true);
@@ -65,10 +69,13 @@
            this.lewyField.setString(null);
            this.resultText.setText("Podaj wszystkie dane.");
            
            Display.getDisplay(this.midlet).setCurrentItem(this.kontraktField);
            this.midlet.display.setCurrentItem(this.kontraktField);
        }
        else if (command.getCommandType() == Command.EXIT) {
            this.midlet.destroyApp(true);
        else if (command.getCommandType() == Command.OK) {
            if(this.menu == null) {
                this.menu = new BrydzMenu(this.midlet, this);
            }
            this.midlet.display.setCurrent(this.menu);
        }
    }
    
@@ -89,9 +96,7 @@
        }
        
        BrydzWynik wynik;
        String data = "";
        if( kontrakt < 0  || kontrakt > 7 ) {
            this.resultText.setText("Niepoprawny kontrakt.");
            return;
@@ -107,7 +112,7 @@
            return;
        }
        
        if( partia != 0 && partia != 1) {
        if( partia < 0 || partia > 3) {
            this.resultText.setText("Niepoprawna informacja o partii.");
            return;
        }