Skip to content

Instantly share code, notes, and snippets.

@chtitux
Created January 11, 2011 21:01
Show Gist options
  • Save chtitux/775135 to your computer and use it in GitHub Desktop.
Save chtitux/775135 to your computer and use it in GitHub Desktop.
// src/hassen/automation/configurator/Document.java
package hassen.automation.server;
public class Document implements IDeviceManager, IEventProcessor {
// ...
private Mapping getMapping (int id) {
for (Mapping m : getMappings()) {
if (m.getId() == id) return m;
}
return null;
}
// ...
}
package hassen.automation.configurator;
public class Main {
// ...
private int getInteger (int max) {
int number = -1;
while (number == -1) {
System.out.print("Chose # : ");
try {
String text = input.readLine();
number = Integer.parseInt(text);
if (number >= max) number = -1;
} catch (Exception e) {
e.printStackTrace();
}
}
return number;
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment