private static void removeEntry(InOut in, AddressBook book) { String name = in.nextLine("Enter name: "); String key = in.nextLine("Enter key: "); String value = book.remove(name, key); if (value == null) in.message("entry not found"); else in.message("Removed entry with value: " + value); }
private static void lookupEntry(InOut in, AddressBook book) { String name = in.nextLine("Enter name: "); String key = in.nextLine("Enter key: "); String value = book.get(name, key); if (value == null) in.message("No entry"); else in.message("Value: " + value); }
private static void addChangeEntry(InOut in, AddressBook book) { String name = in.nextLine("Enter name: "); String key = in.nextLine("Enter key: "); String value = in.nextLine("Enter value: "); String oldValue = book.put(name, key, value); if (oldValue == null) in.message("Entry added"); else in.message("Entry updated"); }
/** fulfil the books informations */ public void start() { try { // TODO code application logic here handler.initReader(); String line = handler.readLine(); if (line.equals("Rank,Title,FoR1,FoR1 Name,FoR2,FoR2 Name,FoR3,FoR3 Name")) { System.out.println("Welcome to the librairy application."); System.out.println("Wait for the application init...."); while (!handler.isEndOfFile()) { line = handler.readLine(); if (line == null) break; else { Revue revueRead = constructRevue(line); map.put(revueRead.getTitle().toUpperCase(), revueRead); // L'enregistrement de la clé sous forme majuscule prend son sens lors de la recherche. } } handler.closeReader(); } else { System.out.println( "Entete du fichier incorrecte! Veuillez verifier le fichier de donnée et recommencer."); } handler.closeReader(); } catch (InOutException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } }
public void comprobar(int i, int j) { // Analizaremos cada variable posible con condicionales para poder determinar // en que posicion esta cada imagen y revisar si esta repetida con esto sabremos si // se hizo la pareja correctamente o no y si no se devolveran a la imagen por defecto // y cuando la cantidad de parejas sea la determinada se reiniciara el juego if (parejas[i][j].getIcon().equals(vacio)) { comprobar++; if (comprobar != 3) { parejas[i][j].setIcon(ima[ficha[i][j]]); } if (comprobar == 1) { pos1 = ficha[i][j]; i1 = i; j1 = j; } if (comprobar == 2) { this.setJugadas(jugadas + 1); ven.actualizarPie(); if (pos1 == ficha[i][j]) { hechas++; comprobar = 0; } else { i2 = i; j2 = j; } } if (comprobar == 3) { parejas[i1][j1].setIcon(vacio); parejas[i2][j2].setIcon(vacio); comprobar = 1; parejas[i][j].setIcon(ima[ficha[i][j]]); pos1 = ficha[i][j]; i1 = i; j1 = j; } if (hechas == getC()) { String s = "Fin del Juego\n"; s = s + "N° de Jugadas: "; io.mostrarStr(s + this.getJugadas()); finJuego(); } } }
private static void processCommands(InOut in, AddressBook book) { String commands = "1: Add/Change Entry\n" + "2: Look Up Entry\n" + "3: Remove Entry\n" + "4: Save Directory\n" + "5: Exit\n" + "Enter Command: "; boolean done = false; while (!done) { String choice = in.nextLine(commands); if (choice.equals("1")) addChangeEntry(in, book); else if (choice.equals("2")) lookupEntry(in, book); else if (choice.equals("3")) removeEntry(in, book); else if (choice.equals("4")) book.save(); else if (choice.equals("5")) done = true; else System.out.println("Not a valid option:" + choice); } }