wie sollte ich meine wechseln Sie zurück zum Haupt-switch?

guten Tag... ich bin erstellen Sie ein Adressbuch-Programm... benutzte ich einen Schalter in meinem Hauptmenü... und Planung erstellen Sie einen weiteren Schalter für mein Menü Bearbeiten... mein problem ist.. ich weiß nicht, wie man wieder zu meiner Haupt-Schalter... das ist mein Main Programm:

import javax.swing.JOptionPane;
import javax.swing.JTextArea;

public class AddressBook {

    private AddressBookEntry entry[];
    private int counter;

    public static void main(String[] args) {
        AddressBook a = new AddressBook();
        a.entry = new AddressBookEntry[100];
        int option = 0;
        while (option != 6) {
            String content = "Choose an Option\n\n"
                    + "[1] Add an Entry\n"
                    + "[2] Delete an Entry\n"
                    + "[3] Update an Entry\n"
                    + "[4] View all Entries\n"
                    + "[5] View Specific Entry\n"
                    + "[6] Exit";
            option = Integer.parseInt(JOptionPane.showInputDialog(content));
            switch (option) {
                case 1:
                    a.addEntry();
                    break;
                case 2:

                    break;
                case 3:
                    a.editMenu();
                    break;
                case 4:
                    a.viewAll();
                    break;
                case 5:
                    break;
                case 6:
                    System.exit(1);
                    break;
                default:
                    JOptionPane.showMessageDialog(null, "Invalid Choice!");
            }
        }
    }

    public void addEntry() {
        entry[counter] = new AddressBookEntry();
        entry[counter].setName(JOptionPane.showInputDialog("Enter name: "));
        entry[counter].setAdd(JOptionPane.showInputDialog("Enter add: "));
        entry[counter].setPhoneNo(JOptionPane.showInputDialog("Enter Phone No.: "));
        entry[counter].setEmail(JOptionPane.showInputDialog("Enter E-mail: "));
        counter++;
    }

    public void viewAll() {
        int i = 0;
        for (; i < counter; i++) {
            JOptionPane.showMessageDialog(null, new JTextArea(entry[i].getInfo()));
        }
    }

    public void editMenu() {
        int option = 0;
        while (option != 6) {
            String content = "Choose an Option\n\n"
                    + "[1] Edit Name\n"
                    + "[2] Edit Address\n"
                    + "[3] Edit Phone No.\n"
                    + "[4] Edit E-mail address\n"
                    + "[5] Go Back to Main Menu\n";
            option = Integer.parseInt(JOptionPane.showInputDialog(content));
            switch (option) {
                case 1:
                    editEntry();
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    break;
                case 5:
                    break;
                default:
                    JOptionPane.showMessageDialog(null, "Invalid Choice!");
            }
        }
    }

    public void editEntry() {
        String EName;
        EName = JOptionPane.showInputDialog("Enter name to edit: ");
        for (int i = 0; i < counter; i++) {
            if (entry[i].getName().equals(EName)) {
                entry[i].setName(JOptionPane.showInputDialog("Enter new name: "));
            }
        }
    }
}

bitte um Hilfe... vielen Dank im Voraus 🙂

  • ich Frage mich, ob ich Springen wie in C, aber ich weiß nicht, wie zu benutzen es hier in Java.. bitte um Hilfe... danke wieder im Voraus
Schreibe einen Kommentar