method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
4979c395-94e4-482a-b763-b9fc3c9415c2 | 4 | private void teamMatches()
{
clear();
try
{
ArrayList<Team> teams = teammgr.listAll();
printShowHeader();
for (Team t : teams)
{
System.out.println(t);
}
System.out.println("Select team id: ");
int id = new Scanner(System.in).nextInt();
Team tm = teammgr.getById(id);
if (tm != null)
{
ArrayList<MatchScheduling> teamPlay = matchmgr.viewTeamSchedule(id);
printShowGroupScheduleHeader();
for (MatchScheduling t : teamPlay)
{
System.out.printf("%3s %-2d %-6s %-20s %-8s %-20s\n", "", t.getMatchInt(), ":",
teammgr.getById(t.getHomeTeam().getId()).getSchool(), " VS ",
teammgr.getById(t.getGuestTeam().getId()).getSchool());
}
}
else
{
System.out.println("Team does not exist!");
}
}
catch (Exception e)
{
System.out.println("ERROR - " + e.getMessage());
}
pause();
} |
1cd50608-5184-4486-9519-39b52f51f56d | 0 | @Autowired
public void createTemplate(DataSource dataSource) {
this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
} |
2a8cecc8-fc50-4952-9f47-44074ad9caa2 | 0 | public int getWidth() {
return width;
} |
a33d9215-7d71-4642-8af6-4c15f7c1e782 | 4 | @Override
public boolean containsLongArray(String name) {
JOSObject<? , ?> raw = this.getObject(name);
if(raw == null) return false;
if(raw.getName().equalsIgnoreCase(LONG_ARRAY_NAME)) return true;
return false;
} |
85b8dd85-d8bb-4172-8a7e-a95d9db3819d | 8 | public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (!par1World.isRemote)
{
if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && Block.lightOpacity[par1World.getBlockId(par2, par3 + 1, par4)] > 2)
{
par1World.setBlockWithNotify(par2, par3, par4, Block.dirt.blockID);
}
else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
{
for (int var6 = 0; var6 < 4; ++var6)
{
int var7 = par2 + par5Random.nextInt(3) - 1;
int var8 = par3 + par5Random.nextInt(5) - 3;
int var9 = par4 + par5Random.nextInt(3) - 1;
int var10 = par1World.getBlockId(var7, var8 + 1, var9);
if (par1World.getBlockId(var7, var8, var9) == Block.dirt.blockID && par1World.getBlockLightValue(var7, var8 + 1, var9) >= 4 && Block.lightOpacity[var10] <= 2)
{
par1World.setBlockWithNotify(var7, var8, var9, Block.grass.blockID);
}
}
}
}
} |
504b4d53-6cdc-44b2-b303-24acbeebf3e3 | 4 | protected void addOnLoaded(Handler<T> doneHandler) {
//once loaded is true, it will never go back to false.
//even if double checked locking fails and we incorrectly go into the synchronized block,
//no harm will be done because by the end, we'll see that loaded is in fact true.
//thus, double checked locking enables us to safely avoid synchronization when possible.
boolean loaded = this.loaded;
if (!loaded) {
synchronized (monitor) {
loaded = this.loaded;
if (!loaded)
listeners.add(doneHandler);
}
}
if (loaded)
if (success)
doneHandler.handle(self);
else
doneHandler.handle(null);
} |
24be6d27-5bb1-46cb-934a-8b1396f4ac42 | 2 | private int findMonth (String input) {
Scanner s = new Scanner (input);
int[] date = new int[3];
s.useDelimiter("/");
while(s.hasNext()) {
for (int i = 0; i < date.length; i++) {
date[i] = s.nextInt();
}
}
s.close();
return date[0];
} |
45709c39-ed3d-41e3-9096-b1df55481596 | 0 | public CarBuilder setBuiltOn(Date builtOn) {
delegate.setBuiltOn(builtOn);
return this;
} |
448154b4-3bd7-474e-8600-b91dd5834e7d | 5 | @SuppressWarnings("unused")
public void buildPanel() {
this.setBounds(150, 250, widthPanelWin, heightPanelWin);
this.setVisible(false);
this.setBackground(Color.BLACK);
JLabel label = new JLabel();
label.setText("Hourra ! Vous vous en êtes bien tiré ! Vous avez éliminé tous vos adversaires ! Bravo !");
this.add(label);
//Nouveau bouton Relancer une partie
JButton newGameButton = new JButton("New Game ?");
newGameButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// We create the new instance of the JFrame to run the game
AppliWindow window;
try {
// AppliWindow is a Singleton
window = AppliWindow.getInstance();
window.init("Tower-IMAC-Nano Prout !", 800, 600, true, Theme.pathImageMap);
window.setVisible(true); // And we make it visible
} catch (MapFileException e) {
e.printStackTrace();
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (RealPlayerException e) {
e.printStackTrace();
}
}
});
}
});
this.add(newGameButton);
//Nouveau bouton Menu Principal
JButton menuPrincipalButton = new JButton("Menu Principal");
menuPrincipalButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//On relance le jeu si on veut recommencer une partie
for(Player p : Game.getInstance().getPlayerManager().getPlayers()) {
p = null;
}
//On nettoie la fenêtre courante et tous ses élèments
AppliWindow.getInstance().dispose();
System.out.println("Youhou ! new Game");
// On relance le jeu en appelant la methode statique main() du Launcher
Launcher.main(null);
}
});
this.add(menuPrincipalButton);
} |
931bdd32-6ed2-4398-a47a-e631083afb78 | 8 | public static boolean checkFileFormat(File file) {
if (!file.exists() && !file.isFile())
return false;
try {
AudioFormat format = AudioSystem.getAudioFileFormat(file)
.getFormat();
if ((format.getEncoding() == AudioFormat.Encoding.PCM_SIGNED || format
.getEncoding() == AudioFormat.Encoding.PCM_UNSIGNED)
&& format.getSampleSizeInBits() == BIT_DEPTH
&& format.getSampleRate() == SAMPLE_RATE)
return true;
} catch (UnsupportedAudioFileException e) {
System.err.println("error: unsupported audio format in file "
+ file.getName());
} catch (IOException e) {
System.err.println("error: could not read file " + file.getName());
}
return false;
} |
69c119f4-7531-442a-be81-e1cfc0dc9802 | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof User))
return false;
User other = (User) obj;
if (ID != other.ID)
return false;
if (nick == null) {
if (other.nick != null)
return false;
} else if (!nick.equals(other.nick))
return false;
return true;
} |
904716f4-de8c-4d28-a0f5-7fab2ab1f9d2 | 1 | public void startSQL() {
try {
InputStream in = this.getClass().getResourceAsStream("/sols/Util/jdbc.properties");
Properties pp = new Properties();
pp.load(in);
url = pp.getProperty("jdbc.url");
user = pp.getProperty("jdbc.username");
password = pp.getProperty("jdbc.password");
driver = pp.getProperty("jdbc.driver");
} catch (IOException ex) {
Logger.getLogger(SQLHelper.class.getName()).log(Level.SEVERE, null, ex);
}
} |
23af6b59-0425-4862-b40a-94860d22049c | 8 | @Override
public Type getType() {
// left and right must be the same type
if (oper == Symbol.EQ || oper == Symbol.NEQ || oper == Symbol.LE || oper == Symbol.LT
|| oper == Symbol.GE || oper == Symbol.GT) {
return Type.booleanType;
} else if (oper == Symbol.AND || oper == Symbol.OR) {
return Type.booleanType;
} else {
return Type.intType;
}
} |
3123afac-e842-4ff6-8983-123198842d4c | 2 | public void mutate() {
cachedTotalOverlap = null;
GeometryFactory factory = Helper.getGeometryFactory();
for (LabelGene gene : this) {
double overlapArea = getGeneOverlap(gene, factory);
if (overlapArea > 0) {
gene.mutate();
}
}
} |
5d71feac-0a0b-48d1-ba5a-4b04ceb45493 | 3 | public static long sortedExperiment(){
startTime = (new Date()).getTime();
int choice;
Long number;
for(int i = 0; i < NUMBER_OF_CHOICES; i++)
{
choice = choices[i];
number = numbers[choice];
if(!binarySearch(number))
{
System.out.println("Not found");
break;
}
else if(binarySearch(123L))
{
System.out.println("123L found");
break;
}
}
return (new Date()).getTime() - startTime;
} |
bf2b6bdd-0c00-49d5-9917-f489f0a85fe3 | 7 | public static void main(String[] args) {
File file = new File("config.properties");
if (!file.exists()) {
try {
file.createNewFile();
prop.setProperty("maxram", "1024");
prop.store(new FileOutputStream("config.properties"), null);
} catch (IOException e) {
e.printStackTrace();
}
}
try {
prop.load(new FileInputStream(file));
} catch (IOException e) {
e.printStackTrace();
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
for (LookAndFeelInfo info : UIManager
.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
try {
UIManager.setLookAndFeel(UIManager
.getCrossPlatformLookAndFeelClassName());
} catch (Exception e1) {
}
}
UIManager.put("swing.boldMetal", Boolean.FALSE);
initColours();
new JFrameMain();
new Downloader(Type.DOWNLOAD);
new Downloader(
"http://ci.lordsofcode.net/job/TheBukkitLauncher-Plugin/lastSuccessfulBuild/artifact/Bukkit-Launcher-Plugin/target/Bukkit-Launcher-Plugin-0.1.0-ALPHA.jar",
"launcher_plugin.jar", new File("bukkit/plugins"),
Type.DOWNLOAD);
usage();
}
});
} |
d9c9cfeb-8e24-4073-862b-ec5192f4dd43 | 1 | @Override
public void start()
throws Exception {
String[] args= this.par.getArgs();
int inputNumberValues= args.length - 1; //-1 for command word
if(inputNumberValues < 1)
throw new Exception("No file to plot");
Plotter.plot(args);
} |
1c48914d-4998-4f87-a7b7-bdf7b50c95db | 0 | @Override
public void paint(Graphics g, Point position) {
g.setColor(this.getColor());
g.fillRect(position.x, position.y, this.width*POSITION_MULTIPLYER, this.height*POSITION_MULTIPLYER);
} |
3d72a82a-fc0d-43f0-838b-84dc48ba307f | 9 | @SuppressWarnings("unchecked")
private void extendStack(int argSize) {
T[] newStack = (T[]) Array.newInstance(sClass, argSize);
if (stack != null) {
System.arraycopy(stack, 0, newStack, 0, size);
}
for (int i = 0; i < newStack.length; i++) {
try {
if (params != null) {
newStack[i] = sClass.getConstructor(params).newInstance(args);
} else {
newStack[i] = sClass.newInstance();
}
} catch (InstantiationException e) {
log.error("Error creating pooled object " + sClass.getSimpleName(), e);
assert (false) : "Error creating pooled object " + sClass.getCanonicalName();
} catch (IllegalAccessException e) {
log.error("Error creating pooled object " + sClass.getSimpleName(), e);
assert (false) : "Error creating pooled object " + sClass.getCanonicalName();
} catch (IllegalArgumentException e) {
log.error("Error creating pooled object " + sClass.getSimpleName(), e);
assert (false) : "Error creating pooled object " + sClass.getCanonicalName();
} catch (SecurityException e) {
log.error("Error creating pooled object " + sClass.getSimpleName(), e);
assert (false) : "Error creating pooled object " + sClass.getCanonicalName();
} catch (InvocationTargetException e) {
log.error("Error creating pooled object " + sClass.getSimpleName(), e);
assert (false) : "Error creating pooled object " + sClass.getCanonicalName();
} catch (NoSuchMethodException e) {
log.error("Error creating pooled object " + sClass.getSimpleName(), e);
assert (false) : "Error creating pooled object " + sClass.getCanonicalName();
}
}
stack = newStack;
size = newStack.length;
} |
5399eed2-4ad9-4985-b710-7275c9558906 | 3 | public void setDefaultValues(FileConfiguration config, Map<String, Object> configParams) {
if (config == null) return;
for (final Entry<String, Object> e : configParams.entrySet())
if (!config.contains(e.getKey()))
config.set(e.getKey(), e.getValue());
} |
7c6e26e7-87b2-479e-95b9-044aa578af7e | 7 | public void add(double value) {
totalCount++;
compCount++;
if (value < start) {
others++;
return;
} else if (value > end) {
compCount++;
others++;
return;
}
compCount++;
latestInRange = value;
// binary search
int low = 0;
int high = rangeCount - 1;
compCount++;
while (low <= high) {
// opCount++;
int mid = (high + low) >>> 1;
compCount++;
if (value <= ranges[mid]) {
compCount += 2;
if (mid > 0 && value < ranges[mid - 1]) {
// continue search
high = mid - 1;
} else {
// we've found the range: ranges[mid]
counts[mid]++;
return;
}
} else if (value > ranges[mid]) {
compCount++;
low = mid + 1;
} else {
compCount++;
}
}
} |
c04a2f36-9e1c-469d-8792-d05a55759166 | 0 | public Piece getPiece(Position pos){
return board[pos.getY()][pos.getX()];
} |
2ad7e322-634c-414e-8e98-ee407830dbcd | 1 | public SchlangenGlied getLastGlied() {
if (nextGlied != null) {
return nextGlied.getLastGlied();
} else {
return this;
}
} |
1d16dde1-385b-4d0a-b79f-e12ed5ec8de3 | 0 | @Test
public void testGetProductCode() throws Exception {
assertTrue(product.getProductCode()=='A');
} |
080174ef-e5c9-4a61-b5de-6a41522163a1 | 4 | private List<String> getValues (String key) {
if (null == key)
throw new NullPointerException( "key must not be null" );
List<String> values = keys.get( key );
if (values != null) return values;
if (validate) this.validateKey( key );
synchronized (keyLock) {
// it might have been created while we were waiting on the lock
values = keys.get( key );
if (values != null) return values;
values = new ArrayList<String>();
keys.put( key, values );
}
return values;
} |
aa6175b2-a0e5-439a-bbe0-2d7be75e6c10 | 4 | public boolean validateInput() {
for(int i = 0; i < 9; i++) {
for(int j = 0; j < 9; j++) {
try {
if(Integer.parseInt(entries[i][j].getText()) < 1) {
return false;
}
}
catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Invalid input. Enter an integer at row "
+ (i + 1) + " column " + (j + 1), "Error", JOptionPane.ERROR_MESSAGE);
return false;
}
}
}
return true;
} |
66904196-8788-4eee-94e6-ee35dfa9877b | 6 | @Override
public String process(List<String> params) throws Router.RedirectSystemError, IOException, Router.RedirectPageNotFound, Router.Redirect, SQLException, MessageException.ErrorMessage {
AuthView view;
switch (getActionByParam(params)) {
case "register":
view = new RegisterView();
if (null != Registry.getInst().getRequestParam("register")) {
try {
String email = Registry.getInst().getRequestParam("email");
String password = Registry.getInst().getRequestParam("pass");
int humanId = register(email, password);
} catch (AuthDAO.LoginIncorrect | AuthDAO.LoginExists e) {
MessageException loginIncorrect = new MessageException.ErrorMessage(e.getMessage()).setName("loginIncorrect");
view.addMessage(loginIncorrect);
}
}
HashMap<String, String> formParams = new HashMap<String, String>();
formParams.put("email", Registry.getInst().getRequestParam("email"));
formParams.put("pass", Registry.getInst().getRequestParam("pass"));
view.setData(formParams);
break;
case "login":
view = new LoginView();
try {
login();
} catch (LoginFail e) {
view.addMessage(e);
}
break;
case "":
view = new MainView();
break;
default:
throw new Router.RedirectPageNotFound();
}
return view.parse();
} |
d78e0c8e-c11a-4788-8d89-9ba441692deb | 3 | private static String leadz(int nr){
if(nr < 100 && nr > 10){
return("0"+nr);
} else if(nr < 10){
return("00"+nr);
} else{
return(""+nr);
}
} |
68cdc6f1-86cb-48d8-8aca-1e47233a02b4 | 1 | public static void main(String[] args) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
// StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
JavaSourceFromString javaSourceFromString = new JavaSourceFromString(
"CalculatorTest",
"public class CalculatorTest {"
+ " public int multiply(int multiplicand, int multiplier) {"
+ " System.out.println(multiplicand);"
+ " System.out.println(multiplier);"
+ " return multiplicand * multiplier;" + " }" + "}");
JavaCompiler.CompilationTask task = compiler.getTask(null, null,
null, Arrays.asList("-d","f:/"),//class文件输出路径
null, Arrays.asList(javaSourceFromString));
Boolean result = task.call();
System.out.println(result);
if (result) {
URL[] urls=new URL[]{new URL("file:/f:/")};
URLClassLoader classLoader=new URLClassLoader(urls);
Class clazz = classLoader.loadClass("CalculatorTest");
Object instance = clazz.newInstance();
Method m = clazz.getMethod("multiply", new Class[] { int.class,
int.class });
Object[] o = new Object[] { 3, 2 };
System.out.println(m.invoke(instance, o));
}
} |
7de1e143-4030-4b2b-9b0b-57bbbc6ef98f | 8 | private CobolToken parseString(final CobolLine cobolLine, final int start) {
final String line = cobolLine.getSource();
final int last = line.length() - 1;
char startChar = line.charAt(start);
int index = start + 1;
// Check hexadecimal strings starting with H or X.
if (Character.isLetter(startChar)) {
// Advance index to see the initial quote/semi-quote.
index++;
startChar = line.charAt(start + 1);
}
// Was the previous non-comment/non-empty line a string ending in
// column 72 with a quote?
if (isSpecialContinuation()) {
// The string must begin with quote-quote.
// Do not confuse with a empty string.
index++;
} // Inspect the string, accounting for quote-quote.
int count = 1; // Count the quotes found so far.
do {
while (index <= last && line.charAt(index) != startChar) {
index++;
}
while (index <= last && line.charAt(index) == startChar) {
count++;
index++;
}
} while (index <= last && count % 2 != 0);
return new CobolToken(cobolLine.getLineNumber(), cobolLine.getFirstColumn() + start, line.substring(start, index), CobolType.STRING);
} |
d053503a-567f-4223-9aa5-86022f639a1d | 4 | @SuppressWarnings({"static-access"})
public static int amount (Player player, String[] args) {
int spawnLimit = plugin.maxSpawnLimit;
if ((args.length <= 2)) {
return 1;
} else {
int amount = Integer.parseInt(args[2]);
try {
if (1 > amount) {
amount = Integer.valueOf(1);
player.sendMessage(ChatColor.GOLD + "[More Mobs]" + ChatColor.RED + " Minimum spawn limit is 1!");
}
if (spawnLimit < amount) {
amount = Integer.valueOf(spawnLimit);
player.sendMessage(ChatColor.GOLD + "[More Mobs]" + ChatColor.RED + " Max spawn limit is " + spawnLimit + "!");
}
return amount;
} catch (Exception ex) {
amount = Integer.valueOf(1);
return amount;
}
}
} |
a2b1dfca-222c-4824-8b89-9ea736dc5d1a | 0 | public void setFossil(String value) {
this.fossil = value;
} |
cb1684f5-5f79-45fb-b61e-ac3412fff534 | 8 | static void fill_keybuf(String keybuf, KeyEvent event) {
int modifier_state = event.getModifierState();
if (modifier_state == Event.STATE_SHIFT_MASK)
keybuf += "<Shift>";
if (modifier_state == Event.STATE_LOCK_MASK)
keybuf += "<Lock>";
if (modifier_state == Event.STATE_CONTROL_MASK)
keybuf += "<Control>";
if (modifier_state == Event.STATE_MOD1_MASK)
keybuf += "<Mod1>";
if (modifier_state == Event.STATE_MOD2_MASK)
keybuf += "<Mod2>";
if (modifier_state == Event.STATE_MOD3_MASK)
keybuf += "<Mod3>";
if (modifier_state == Event.STATE_MOD4_MASK)
keybuf += "<Mod4>";
if (modifier_state == Event.STATE_MOD5_MASK)
keybuf += "<Mod5>";
// keybuf += utf8;
} |
6d8473ca-bd06-4593-b3b4-2fbecf9685c5 | 1 | public void succeed() {
if(cb != null)
cb.run();
} |
cd19dfbf-33a0-4718-b6c5-a73dc40cab4a | 4 | public void rMayusCentrosNoLocal(double paramDistancia)
{
Iterator elemFuente;
Elemento entrada,salida;
Iterator elemDestino = destino.listaElementos();
double sumaDistancias,sumaValores,distancia,ponderacion,rMayor;
double dist[];
int count;
while(elemDestino.hasNext()) //Recorre elementos destino
{
sumaDistancias = sumaValores = 0; // inicializa sumas
salida = (Elemento)((Entry)elemDestino.next()).getValue();
elemFuente = fuente.listaElementos(); //carga fuentes
rMayor = 0;
dist = new double[fuente.numeElementos()];
count = 0;
while(elemFuente.hasNext()) //recorre elementos fuente
{
entrada = (Elemento)((Entry)elemFuente.next()).getValue();
distancia = distanciaCentros(entrada,salida);
dist[count] = distancia;
count ++;
rMayor = (distancia > rMayor)?distancia:rMayor;
}
elemFuente = fuente.listaElementos();
count = 0;
while(elemFuente.hasNext()) //recorre elementos fuente
{
double pow = Math.pow((rMayor - dist[count])/(rMayor * dist[count]),2);
sumaDistancias += pow;
sumaValores += pow * ((Elemento)((Entry)elemFuente.next()).getValue()).valor();
count ++;
}
salida.valor(sumaValores / sumaDistancias);
}
} |
1fb3a54f-3a21-4cc3-a018-d531b82afb63 | 1 | @Override
public String getFieldValue(String name) {
String s = map.get(name);
if (s == null) {
return "";
}
return s;
} |
77d91ad8-932d-42b0-8ca8-a13aa9d7b570 | 3 | public static Destructor getDestructorById(String id, War war, String type) {
Vector<Destructor> destructors = null;
int size_launcher = 0;
if (type.equals(main.Program.LAUNCHER)) {
destructors = war.getMissileLauncherDestructors();
}
else {
destructors = war.getMissileDestructors();
}
size_launcher = destructors.size();
for (int i = 0; i < size_launcher; i++) {
Destructor d = destructors.elementAt(i);
if (id.equals(d.getDestructorId())) {
return d;
}
}
return null;
} |
46533f4f-2b12-4f49-8cab-e74ba98f6d7e | 2 | @Override
public int compare(Sample d1, Sample d2) {
if (d1.fx < d2.fx) {
return -1 * order;
} else if (d1.fx == d2.fx) {
return 0 * order;
} else {
return 1 * order;
}
} |
2d8d9b06-32c0-420a-bb27-40da4dd87a9f | 4 | @Override
public W<DeltaSet> delta(DC obj)
{ if(obj instanceof Set)
{ Set that=(Set)obj;
Set<Pair<T,T>> phiMax=getPhiMax(getAllPhis(this,that));
Equality equ=getPhiEqu(phiMax);
int m=this.size();
int n=that.size();
double diffMeasure=(2*getPhiSim(phiMax).getValue()+Similarity.sizeBalance(m,n))/(m+n);
if(equ.getValue() && m==n && phiMax.size()==m)
{ return new W(new Equality(true),new Similarity(0.0),new DeltaSet.Id(this));
}
else
{ return new W(new Equality(false),
new Similarity(diffMeasure),
new DeltaSet( dMax(phiMax),
this.less(dom(phiMax)),
that.less(codom(phiMax))
)
);
}
}
else
{ throw new RuntimeException(obj+" is NOT of type Set.");}
} |
7863f8db-2dc6-4edd-954b-7594a4b92cdc | 2 | private static void output(String out) {
if (LIVE_PRINT) {
System.out.print(out);
}
if (FILE_PRINT) {
writeToFile(out);
}
} |
b91f6e62-984e-43ab-b29f-1a3861928f0a | 2 | protected void drawLists(Graphics g) {
for (Drawable d : drawableList) {
d.draw(g);
}
for (PowerUp p : powerUpList) {
p.draw(g);
}
} |
a053f9f4-4857-4da2-aed6-c4ced1cb1aea | 8 | public void bet(String b) {
try {
this.bet = Integer.parseInt(b);
} catch (Exception e) {
this.validBet = false;
}
while (this.money == 0) {
JOptionPane
.showMessageDialog(null,
"Cannot bet, Out of money!\nRestart Program to play again!");
}
if (this.bet > this.money || this.bet <= 0) {
this.validBet = false;
}
while (!this.validBet) {
try {
this.bet = Integer.parseInt(JOptionPane.showInputDialog(null,
"Please enter a positive integer bet amount that is less than $"
+ this.money, "Invalid Bet", 0));
if (this.bet > this.money || this.bet <= 0) {
this.validBet = false;
} else {
this.validBet = true;
}
} catch (Exception e) {
this.validBet = false;
}
}
this.validBet = true;
this.money -= this.bet;
} |
170eecb7-07c6-4779-8963-e3ddab3a6613 | 8 | public void genWin()
{
for(int i=0; i< win.length; i++)
{
for (int j=0;j<win[0].length;j++)
{
win[i][j] = false;
}
}
for(int i=Partie.DEF_DEPART[0];i<win.length;i++)
{
for(int j= Partie.DEF_DEPART[1];j<win[0].length;j++)
{
if (!win[i][j])
{
int [] temp1 = {i,j};
for(int k=temp1[0];k<win.length;k++)
{
for(int l=temp1[1];l<win[k].length;l++)
{
int [] temp = {k,l};
win[k][l] = allowCoord(temp1,temp) && downright(temp1,temp);
}
}
}
}
}
/*/
for(int i=0; i< win.length; i++)
{
System.err.print("{ ");
for (int j= 0;j< win.length; j++)
{
System.err.print(win[i][j] + ", ");
}
System.err.println("}");
}
System.exit(0);
//*/
} |
1a3d4253-8641-4e9a-b12b-63f76893be52 | 0 | public void setjButtonDetails(JButton jButtonDetails) {
this.jButtonDetails = jButtonDetails;
} |
ba5b6933-8760-4e19-8a0f-fc8d8ebc053e | 4 | public static int[][] exempleCarte()
{
final int[][] carte = new int[LARGEUR_GRILLE][HAUTEUR_GRILLE];
int i;
int j;
for (i = 0; i < LARGEUR_GRILLE; i++) {
carte[i][0] = 0;
carte[i][HAUTEUR_GRILLE - 1] = 0;
}
for (j = 0; j < HAUTEUR_GRILLE; j++) {
carte[0][j] = 0;
carte[LARGEUR_GRILLE - 1][j] = 0;
}
for (i = 1; i < LARGEUR_GRILLE - 1; i++) {
for (j = 1; j < HAUTEUR_GRILLE - 1; j++) {
carte[i][j] = 1;
}
}
return carte;
} |
babade36-0ce8-4382-b4d4-e368345a05ce | 2 | @Test
public void testConstructorValid(){
// Create a PlayerInfo, and test that our construction works accordingly.
IPlayer player = new DummyPlayer();
PlayerInfo playerInfo = new PlayerInfo(player);
assertEquals("Player instance did not set properly in PlayInfo.", player, playerInfo.getPlayer());
// Check hand pile
assertTrue("Player should have a valid hand pile.", playerInfo.getHandPile() != null);
if(playerInfo.getHandPile() != null)
assertTrue("Player's hand pile shouldn't have cards in it upon PlayerInfo construction.", playerInfo.getHandPile().getNumCards() == 0);
// Check tricks won pile
assertTrue("Player should have a valid tricks won pile.", playerInfo.getTricksWonPile() != null);
if(playerInfo.getTricksWonPile() != null)
assertTrue("Player's tricks won pile shouldn't have cards in it upon PlayerInfo construction.", playerInfo.getTricksWonPile().getNumCards() == 0);
assertTrue("Player's game score should be 0 upon PlayerInfo construction.", playerInfo.getGameScore() == 0);
} |
f6eefada-b7fe-4ac4-8dde-325c93de8897 | 4 | private byte[] readDataFromFile(String filePath) throws Exception {
File file = new File(filePath);
long fileLength = file.length();
byte[] dataBuffer = new byte[(int) fileLength];
InputStream inputStream = new FileInputStream(file);
try {
int offset = 0;
int numRead = 0;
while (true) {
if (offset >= dataBuffer.length) {
break;
}
numRead = inputStream.read(dataBuffer, offset, dataBuffer.length - offset);
if (numRead < 0) {
break;
}
offset += numRead;
}
if (offset < dataBuffer.length) {
throw new IOException("Could not completely read file "
+ file.getName());
}
} finally {
inputStream.close();
}
return dataBuffer;
} |
5221342c-4186-4ace-9c01-a93a699d7998 | 8 | @Override
public void run() {
String msg = "!auction-ended " + getHighestBidder().getName() + " " + printHighestAmount() + " " + getDescribtion();
try {
// if owner is online- send notification
if (userManagement.getUserByName(owner.getName()).isOnline()) {
// AuctionServer_UDPSocket.getInstamce().sendMessage(owner.getInternetAdress(), owner.getUdpPort(), msg);
} else { // else save the notification until user gets online again
userManagement.getUserByName(owner.getName()).storeNotification(msg);
}
// just if a highest bidder exist
if (!getHighestBidder().getName().equals("none")) {
// if highest bidder is online send notification
if (userManagement.getUserByName(getHighestBidder().getName()).isOnline()) {
// AuctionServer_UDPSocket.getInstamce().sendMessage(getHighestBidder().getInternetAdress(), getHighestBidder().getUdpPort(), msg);
} else {
userManagement.getUserByName(getHighestBidder().getName()).storeNotification(msg);
}
// send RMI BID_WON Event
Timestamp logoutTimestamp = new Timestamp(System.currentTimeMillis());
long timestamp = logoutTimestamp.getTime();
try {
mClientHandler.processEvent(new BidEvent(BidEvent.BID_WON, timestamp, getHighestBidder().getName(), id, hightestAmount));
} catch (WrongEventTypeException e) {
// wont happen
} catch (NullPointerException e) {
logger.error("Remote Object is null");
}
// bill auction on the billing server
// TODO for now this is static, but I'd rather obtain the protocoll instance, but where?
CommunicationProtocol.billAuction(getHighestBidder().getName(), id, hightestAmount);
}
// send RMI AUCTION_ENDED Event
Timestamp logoutTimestamp = new Timestamp(System.currentTimeMillis());
long timestamp = logoutTimestamp.getTime();
try {
mClientHandler.processEvent(new AuctionEvent(AuctionEvent.AUCTION_ENDED, timestamp, this.id, durationSec, highestBidder.getName()));
} catch (WrongEventTypeException e) {
// wont happen
} catch (NullPointerException e) {
logger.error("Remote Object is null");
}
// if the auciton server is offline- just flack the auction to inactive. else remoove it.
synchronized (userManagement.syncAuctionList) {
this.setActive(false);
logger.debug("setting aucitons active flag to false");
// if (!AuctionServer.isServerIsOnline()) {
// logger.info("setting aucitons active flag to false");
// this.setActive(false);
// } else {
// logger.info("removing auciton from syncAuctionList");
// userManagement.syncAuctionList.remove(this); // delete auction from list
// }
}
} catch (IOException e) {
System.out.println("Didn't send Notification.");
}
} |
d72a195d-cfca-43ef-a2e4-db155501f071 | 7 | public static void main(String[]args){
String Train = args[0];
//String Test = args[1];
//Naive naive = new Naive();
topwordsLogOdds naive = new topwordsLogOdds();
try {
naive.train(Train);
} catch (IOException e) {
e.printStackTrace();
}
//naive.test(Test);
List<Map.Entry<String, Double>> folder = new ArrayList<Map.Entry<String, Double>>(naive.ppMap2.entrySet());
Collections.sort(folder, new Comparator<Map.Entry<String, Double>>() {
public int compare(Map.Entry<String, Double> e1,
Map.Entry<String, Double> e2) {
if (!e1.getValue().equals(e2.getValue())) {
if (e2.getValue() > e1.getValue()) return 1;
else return -1;
} else
return (e1.getKey()).toString().compareTo(e2.getKey().toString());
}
});
for(int i = 0; i < 20; i++){
System.out.printf(folder.get(i).getKey() + " %.04f" + "\n", folder.get(i).getValue());
}
System.out.printf("\n");
folder = new ArrayList<Map.Entry<String, Double>>(naive.ppMap.entrySet());
Collections.sort(folder, new Comparator<Map.Entry<String, Double>>() {
public int compare(Map.Entry<String, Double> e1,
Map.Entry<String, Double> e2) {
if (!e1.getValue().equals(e2.getValue())) {
if (e2.getValue() > e1.getValue()) return 1;
else return -1;
} else
return (e1.getKey()).toString().compareTo(e2.getKey().toString());
}
});
for(int i = 0; i < 20; i++){
System.out.printf(folder.get(i).getKey() + " %.04f" + "\n", folder.get(i).getValue());
}
} |
b2d608b6-a2f9-43f2-b5f6-870f803ba3b9 | 9 | synchronized void doneWork() {
boolean doneTicking = true;
if (timer.isRunning) doneTicking = false;
for (TickThread thread : this.threadPool) {
if (thread.isWorking) doneTicking = false;
}
if (!doneTicking) {
try {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
synchronized(listRemove) {
for (ITickable tick : this.listRemove) {
this.listDone.remove(tick);
}
}
synchronized(listAdd) {
for (ITickable tick : this.listAdd) {
if (tick != null)
this.listDone.add(tick);
}
}
listRemove.clear();
listAdd.clear();
listWork.clear();
synchronized(listDone) {
for (ITickable tick : this.listDone) {
this.listWork.add(tick);
}
}
listDone.clear();
notifyAll();
}
} |
e947b7e6-8e5a-455a-b9d0-78ca9c7f44d0 | 4 | @Override
public boolean handleAfterCall(int currentAddress, int callAddress, CPUState s, boolean reachable) {
if(callAddress == 0x10) { // rst $10: BankSwitch
if(s.rMask[CPUState.A] == 0xFF)
s.loadedBank = s.r[CPUState.A] & 0x7F;
else
s.loadedBank = -1;
return true;
}
if (callAddress >= 0x4000 || callAddress == 0x0dc3) {
s.invalidateRegisters();
return true;
}
return false;
} |
a18783b5-4038-44ea-bae6-e7bab4ae8927 | 4 | private void placeWarMachine(WarMachine warMachine, Koordinate koord,
Ausrichtung ausrichtung) throws InvalidPlacementException {
Koordinate min = getMin(warMachine, koord, ausrichtung);
Koordinate max = getMax(warMachine, koord, ausrichtung);
for (int i = min.getY(); i <= max.getY(); i++) {
// Pruefen ob bereits andere WarMachines auf den Feldern sind
for (int j = min.getX(); j <= max.getX(); j++) {
if (elements[j][i].getWarMachine() != null)
throw new InvalidPlacementException();
}
// Warmachine anmelden
for (int j = min.getX(); j <= max.getX(); j++) {
elements[j][i].anmelden(warMachine);
}
}
} |
5af2c9d5-593a-40a7-aa59-085d0b14b331 | 1 | public T get(PK id) {
T entity = (T) hibernateTemplate.get(this.persistentClass, id);
if (entity == null) {
log.warn("Uh oh, '" + this.persistentClass + "' object with id '" + id + "' not found...");
throw new ObjectRetrievalFailureException(this.persistentClass, id);
}
return entity;
} |
2cc91306-f9b1-4c4e-bf6c-9db5468f3706 | 0 | public void setFirst(T newValue) { first = newValue; } |
d90a0d66-9fca-4f37-aa44-e42276258000 | 9 | static private int jjMoveStringLiteralDfa0_0()
{
switch(curChar)
{
case 40:
return jjStopAtPos(0, 20);
case 41:
return jjStopAtPos(0, 21);
case 45:
return jjMoveStringLiteralDfa1_0(0x1000000L);
case 60:
return jjMoveStringLiteralDfa1_0(0x2000000L);
case 94:
return jjStopAtPos(0, 23);
case 102:
return jjMoveStringLiteralDfa1_0(0x400L);
case 116:
return jjMoveStringLiteralDfa1_0(0x200L);
case 118:
return jjStartNfaWithStates_0(0, 11, 14);
case 126:
return jjStopAtPos(0, 22);
default :
return jjMoveNfa_0(0, 0);
}
} |
fae3d527-bc92-4be2-a981-8bfc05dbeecf | 6 | public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(FormularioCompresor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FormularioCompresor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FormularioCompresor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FormularioCompresor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FormularioCompresor().setVisible(true);
}
});
} |
d912a66a-83db-4a35-bb59-aff9d24ffef0 | 4 | static void updateWinCount() throws IOException
{
if(computer)
{
console.setText(winC()+" wins!");
if(winC()=="Red")
{
redwins++;
reds.save(redwins+"");
}
else if(winC()=="Blue")
{
bluewins++;
blues.save(bluewins+"");
}
}
else
{
if(player==0)
{
console.setText("Red wins!");
redwins++;
reds.save(redwins+"");
}
else
{
console.setText("Blue wins!");
bluewins++;
blues.save(bluewins+"");
}
}
red.setText("Red:"+redwins);
blue.setText("Blue:"+bluewins);
} |
cdf8d31f-ceaf-4f4f-87e0-d63c39d2dc93 | 4 | public void sipsSigmoidFit(){
if(this.nAnalyteConcns<4)throw new IllegalArgumentException("Method sipsSigmoidFit requres at least 4 data points; only " + this.nAnalyteConcns + " were supplied");
this.methodUsed = 6;
this.sampleErrorFlag = true;
this.titleOne = "Sips sigmoid fitting: r = Aa^n/(theta^n + a^n)";
if(!this.setDataOneDone)this.setDataOne();
super.addConstraint(0, -1, 0.0);
super.sigmoidHillSips();
super.removeConstraints();
for(int i=0; i<this.nInterp; i++){
this.calculatedResponses[i] = super.best[2]*Math.pow(this.interpolationConcns[i], super.best[1])/(Math.pow(super.best[0], super.best[1]) + Math.pow(this.interpolationConcns[i],super.best[1]));
}
if(!this.supressPlot)this.plott();
this.curveCheck(this.methodIndices[this.methodUsed]);
} |
b000c39d-8a09-42f5-925c-edd8eb4d25ef | 3 | public void error(Throwable e, String message) {
if (verbose && (e != null)) e.printStackTrace();
if (!quiet) System.err.println(message);
} |
cbe02121-a49c-4c2f-8660-f714624ddf2b | 3 | public void saveScores() {
try {
File file = new File(
"scores.txt");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
for (Person p : people) {
bw.write(p.getName() + "\n");
bw.write(p.getScore() + "\n");
}
bw.close();
} catch (Exception e) {
System.out.println("can't write to usedcommands.txt...");
}
} |
093b1a64-fab3-4e9a-b5b7-ae45ea3e1977 | 1 | public Object pop() throws EmptyException {
if (list.isEmpty()) {
throw new EmptyException();
}
return list.popBack().getItem();
} |
7024f9aa-70de-495a-b6c9-46a13d83d080 | 2 | private byte[] readStream(InputStream fin) throws IOException {
byte[] buf = new byte[4096];
int size = 0;
int len = 0;
do {
size += len;
if (buf.length - size <= 0) {
byte[] newbuf = new byte[buf.length * 2];
System.arraycopy(buf, 0, newbuf, 0, size);
buf = newbuf;
}
len = fin.read(buf, size, buf.length - size);
} while (len >= 0);
byte[] result = new byte[size];
System.arraycopy(buf, 0, result, 0, size);
return result;
} |
ddf38127-7218-488f-bdeb-b8ba80db1a6e | 6 | public static void main(String[] args){
log.info("--Start");
log.info("Read application config");
Config config = getConfig();
//
ArgumentParser parser = ArgumentParsers.newArgumentParser("rni")
.description("Process rni load testing");
Subparsers subparsers = parser.addSubparsers().help("");
Subparser run = subparsers.addParser("run").help("Run test plan");
run.addArgument("--test_plan")
.type(Arguments.fileType().verifyIsFile())
.required(true)
.help("Path to the test plan");
run.addArgument("--set_plan")
.type(Boolean.class)
.required(false)
.setDefault(false)
.help("If true, test plan .jmx will be edited with parameters set in test plan config");
Subparser status = subparsers.addParser("status").help("Check test execution status");
Subparser result = subparsers.addParser("prepare_results").help("Process result .csv files");
result.addArgument("--clear_trans_samplers")
.type(Boolean.class)
.setDefault(true)
.help("Remove transaction controllers from results");
Subparser loadosophia = subparsers.addParser("loadosophia").help("Upload results to Loadosophia.org");
loadosophia.addArgument("--target_file")
.type(Arguments.fileType().verifyIsFile())
.required(true)
.help("Define a file that will be a target file for Loadosophia.org");
loadosophia.addArgument("--other_files")
.type(Arguments.fileType().verifyIsFile())
.required(false)
.nargs(1)
.help("Define other files that needs to be uploaded to Loadosophia.org");
Namespace res = null;
try {
res = parser.parseArgs(args);
} catch (ArgumentParserException e) {
parser.handleError(e);
System.exit(1);
}
String command = args[0];
if(command == null){
log.log(Level.SEVERE, "Missing command");
System.exit(1);
} else if(command.equals("run")){
run(config, res);
} else if(command.equals("status"))
{
//TODO: status method
} else if(command.equals("prepare_results")){
prepareResults(config, res);
} else if (command.equals("loadosophia")){
uploadResults(config, res);
}
//
log.info("--Exit");
} |
2c22d5a2-6def-4cc6-aa0e-5d290629bfd8 | 0 | public static ArrayList<Pet> arrayList(int size) {
return creator.arrayList(size);
} |
d3a97432-ba10-4991-8461-923639f3f4da | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
User other = (User) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (password == null) {
if (other.password != null)
return false;
} else if (!password.equals(other.password))
return false;
return true;
} |
0c59ed41-0f31-4c58-8748-50b4b5dc9e63 | 5 | private final void init (boolean flag) {
int i;
int a, b, c, d, e, f, g, h;
a = b = c = d = e = f = g = h = 0x9e3779b9; // The golden ratio
for (i = 0; i < 4; ++i) {
a ^= b << 11; d += a; b += c;
b ^= c >>> 2; e += b; c += d;
c ^= d << 8; f += c; d += e;
d ^= e >>> 16; g += d; e += f;
e ^= f << 10; h += e; f += g;
f ^= g >>> 4; a += f; g += h;
g ^= h << 8; b += g; h += a;
h ^= a >>> 9; c += h; a += b;
}
for (i = 0; i < SIZE; i += 8) { // Fill in mem[] with messy stuff
if (flag) {
a += rsl[i ]; b += rsl[i + 1]; c += rsl[i + 2]; d += rsl[i + 3];
e += rsl[i + 4]; f += rsl[i + 5]; g += rsl[i + 6]; h += rsl[i + 7];
}
a ^= b << 11; d += a; b += c;
b ^= c >>> 2; e += b; c += d;
c ^= d << 8; f += c; d += e;
d ^= e >>> 16; g += d; e += f;
e ^= f << 10; h += e; f += g;
f ^= g >>> 4; a += f; g += h;
g ^= h << 8; b += g; h += a;
h ^= a >>> 9; c += h; a += b;
mem[i ] = a; mem[i + 1] = b; mem[i + 2] = c; mem[i + 3] = d;
mem[i + 4] = e; mem[i + 5] = f; mem[i + 6] = g; mem[i + 7] = h;
}
if (flag) { // Second pass: makes all of seed affect all of mem[]
for (i = 0; i < SIZE; i += 8) {
a += mem[i ]; b += mem[i + 1]; c += mem[i + 2]; d += mem[i + 3];
e += mem[i + 4]; f += mem[i + 5]; g += mem[i + 6]; h += mem[i + 7];
a ^= b << 11; d += a; b += c;
b ^= c >>> 2; e += b; c += d;
c ^= d << 8; f += c; d += e;
d ^= e >>> 16; g += d; e += f;
e ^= f << 10; h += e; f += g;
f ^= g >>> 4; a += f; g += h;
g ^= h << 8; b += g; h += a;
h ^= a >>> 9; c += h; a += b;
mem[i ] = a; mem[i + 1] = b; mem[i + 2] = c; mem[i + 3] = d;
mem[i + 4] = e; mem[i + 5] = f; mem[i + 6] = g; mem[i + 7] = h;
}
}
isaac ();
count = SIZE;
} |
25555106-0ce3-462c-9505-d25af3a05a84 | 2 | public static String formatTime(long diffLongTime) {
StringBuffer buf = new StringBuffer();
long hours = diffLongTime / (60 * 60 * 1000);
long rem = (diffLongTime % (60 * 60 * 1000));
long minutes = rem / (60 * 1000);
rem = rem % (60 * 1000);
long seconds = rem / 1000;
if (hours != 0) {
buf.append(hours);
buf.append("시간 ");
}
if (minutes != 0) {
buf.append(minutes);
buf.append("분 ");
}
// 차이가 없다면 0을 반환한다.
buf.append(seconds);
buf.append("초");
return buf.toString();
} |
0a2e5ffd-22d1-4654-ba51-0bf15e882884 | 4 | private void checkEnableButtons() {
boolean bool = this.typeName.getText().length() > 0 && this.roomType.getText().length() > 0 && ((Integer)this.minHour.getValue() + (Integer)this.minMin.getValue() > 0) && ((Integer)this.maxHour.getValue() + (Integer)this.maxMin.getValue() > 0);
//System.out.print(bool);
this.addType.setEnabled(bool);
bool = this.fieldName.getText().length() > 0 && this.fieldType.getSelectedItem() != null;
//System.out.print(bool);
this.addField.setEnabled(bool);
} |
e00ef1a0-9005-4934-a021-38cdd217b981 | 3 | @Override
public boolean addPostToMainForum(MainForum mf)
{
{
Session session = null;
boolean succses = true;
try {
session = factory.openSession();
session.beginTransaction();
session.save(mf);
session.getTransaction().commit();
log.info("succseed to add post to main forum");
} catch (HibernateException e) {
if (session != null) {
session.getTransaction().rollback();
log.info("didnt succseed to add post to main forum!!!");
succses = false;
throw new ForumException(e);
}
} finally {
if (session != null) {
session.close();
}
return succses;
}
}
} |
3cb3e4de-543c-42e9-a363-2522fc451e7d | 9 | private static File promptForFtlPath() {
String steamPath = "Steam/steamapps/common/FTL Faster Than Light";
String gogPath = "GOG.com/Faster Than Light";
File[] paths = new File[] {
// Windows - Steam
new File( new File(""+System.getenv("ProgramFiles(x86)")), steamPath ),
new File( new File(""+System.getenv("ProgramFiles")), steamPath ),
// Windows - GOG
new File( new File(""+System.getenv("ProgramFiles(x86)")), gogPath ),
new File( new File(""+System.getenv("ProgramFiles")), gogPath )
// TODO add more
};
File ftlPath = null;
for ( File path: paths ) {
if ( path.exists() ) {
ftlPath = path;
break;
}
}
if ( ftlPath == null ) {
log.trace("FTL path not located automatically. Prompting user for location.");
JOptionPane.showMessageDialog(null, "FTL Profile Editor uses images and data from FTL but was unable to locate your FTL installation.\n" +
"You will now be prompted to locate FTL manually. (You will only need to do this once)", "FTL Not Found", JOptionPane.INFORMATION_MESSAGE);
final JFileChooser fc = new JFileChooser();
fc.addChoosableFileFilter( new FileFilter() {
@Override
public String getDescription() {
return "FTL Data File - (FTLInstall)/resources/data.dat";
}
@Override
public boolean accept(File f) {
return f.isDirectory() || f.getName().equals("data.dat");
}
});
fc.setMultiSelectionEnabled(false);
// TODO Store full data file path - Mac install is packaged and does not have the resources dir
// (Will need to add something to convert existing config files)
if ( fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION ) {
ftlPath = fc.getSelectedFile().getParentFile().getParentFile();
log.trace( "User selected: " + ftlPath.getAbsolutePath() );
} else
log.trace( "User cancelled FTL path selection" );
}
if ( ftlPath != null && ftlPath.exists() && ftlPath.isDirectory() && new File(ftlPath,"resources/data.dat").exists() ) {
log.info( "FTL located at: " + ftlPath.getAbsolutePath() );
return ftlPath;
} else {
log.error( "FTL was not found" );
showErrorDialog( "FTL data was not found.\nFTL Profile Editor will now exit." );
System.exit(1);
}
return null;
} |
b32b2dbf-2873-4f84-b33c-c601032b85c0 | 5 | @Test
public void testInfixToPostfix6() throws DAIllegalArgumentException,
DAIndexOutOfBoundsException, ShouldNotBeHereException,
BadNextValueException, UnmatchingParenthesisException {
try {
infix.addLast("-");
infix.addLast("5");
infix.addLast("/");
infix.addLast("5");
QueueInterface<String> postFix = calc.infixToPostfix(infix);
String result = "24+55/-";
assertEquals(result, calc.stringTrans(postFix));
} catch (DAIllegalArgumentException e) {
throw new DAIllegalArgumentException();
} catch (DAIndexOutOfBoundsException e) {
throw new DAIndexOutOfBoundsException();
} catch (ShouldNotBeHereException e) {
throw new ShouldNotBeHereException();
} catch (BadNextValueException e) {
throw new BadNextValueException();
} catch (UnmatchingParenthesisException e) {
throw new UnmatchingParenthesisException();
}
} |
37d871c7-3d38-497b-b7a2-a9b813aa39e9 | 6 | public boolean open() {
if (isOpen()) {
return true;
}
GameObject box = ctx.objects.getNearest(new Filter<GameObject>() {
@Override
public boolean accept(GameObject element) {
for(int id :DEPOSIT_BOX_IDS) {
if(id == element.getId()) {
return true;
}
}
return false;
}
});
if (box != null) {
box.interact("Deposit");
Timer t = new Timer(3000);
while (!isOpen() && t.isRunning()) {
Utils.sleep(150);
}
}
return isOpen();
} |
c016ca28-5bbf-4d06-a878-ab088539d897 | 1 | public String map2QcTestName(ITestResult res)
{
String methodName = res.getMethod().getMethodName();
String testName = res.getTestClass().getName();
String qcTestName = ("test".equals(methodName) ? testName : testName
+ "-" + methodName); //TestGroup method.
return qcTestName;
} |
c55e52b2-6306-405f-9060-aa3f725578ed | 1 | @Override
public void topicVisibilityChanged(boolean visible) {
for (ChannelTab channel : channelTabs)
channel.setTopicPanelVisibility(visible);
} |
44766e57-78ae-4a1f-b33d-8ac95f99bb92 | 9 | public void addComponents(HBox layout) {
cbMechanics.setItems(FXCollections.observableArrayList("Physics",
new Separator(), "Projectile Motion", "Friction"));
cbWaves.setItems(FXCollections.observableArrayList(
"Optics, Waves and Modern Physics", new Separator(),
"Simple Harmonic Motion", "Doppler Effect"));
cbElectricity.setItems(FXCollections.observableArrayList(
"Electricity and Magnetism", new Separator(), "RC Circuit",
"Lorentz Law"));
// set default value
cbMechanics.getSelectionModel().selectFirst();
cbWaves.getSelectionModel().selectFirst();
cbElectricity.getSelectionModel().selectFirst();
// add listener
cbMechanics.getSelectionModel().selectedIndexProperty()
.addListener(new ChangeListener<Number>() {
@Override
public void changed(
ObservableValue<? extends Number> obsVal,
Number oldVal, Number newVal) {
cbWaves.getSelectionModel().selectFirst();
cbElectricity.getSelectionModel().selectFirst();
btnMenu.setDisable(false);
switch (newVal.intValue()) {
case 2:
addCenterPane(new ProjectileMotion());
break;
case 3:
addCenterPane(new Friction());
break;
}
}
});
cbWaves.getSelectionModel().selectedIndexProperty()
.addListener(new ChangeListener<Number>() {
@Override
public void changed(
ObservableValue<? extends Number> obsVal,
Number oldVal, Number newVal) {
cbMechanics.getSelectionModel().selectFirst();
cbElectricity.getSelectionModel().selectFirst();
btnMenu.setDisable(false);
switch (newVal.intValue()) {
case 2:
addCenterPane(new SHM());
break;
case 3:
addCenterPane(new DopplerEffect());
break;
}
}
});
cbElectricity.getSelectionModel().selectedIndexProperty()
.addListener(new ChangeListener<Number>() {
@Override
public void changed(
ObservableValue<? extends Number> obsVal,
Number oldVal, Number newVal) {
cbWaves.getSelectionModel().selectFirst();
cbMechanics.getSelectionModel().selectFirst();
btnMenu.setDisable(false);
switch (newVal.intValue()) {
case 2:
addCenterPane(new RCCircuit());
break;
case 3:
addCenterPane(new LorentzLaw());
break;
}
}
});
btnMenu.setOnAction(new ButtonListener());
layout.getChildren().add(cbMechanics);
layout.getChildren().add(cbWaves);
layout.getChildren().add(cbElectricity);
layout.getChildren().add(btnMenu);
} |
057dd3e0-5f05-4b95-a177-bdd10c410254 | 6 | RGBA(Color c)
{
switch(c)
{
case BLACK:
r = g = b = 0;
a = 255;
break;
case RED:
r = 255;
g = 0;
b = 0;
a = 255;
break;
case BLUE:
r = 0;
g = 0;
b = 255;
a = 255;
break;
case YELLOW:
r = 192;
g = 192;
b = 0;
a = 255;
break;
case GREEN:
r = 0;
g = 128; // Dark green is better-looking than pure green
b = 0;
a = 255;
break;
case LIGHT_GRAY:
r = 128;
g = 128;
b = 128;
a = 48;
default:
assert false;
}
} |
50230502-8d80-499e-adff-ef83c12e354b | 6 | public static String cppChangeCase(GeneralizedSymbol symbol, Keyword caseconvention) {
{ MemoizationTable memoTable000 = null;
Cons memoizedEntry000 = null;
Stella_Object memoizedValue000 = null;
if (Stella.$MEMOIZATION_ENABLEDp$) {
memoTable000 = ((MemoizationTable)(Stella.SGT_STELLA_F_CPP_CHANGE_CASE_MEMO_TABLE_000.surrogateValue));
if (memoTable000 == null) {
Surrogate.initializeMemoizationTable(Stella.SGT_STELLA_F_CPP_CHANGE_CASE_MEMO_TABLE_000, "(:MAX-VALUES 2000)");
memoTable000 = ((MemoizationTable)(Stella.SGT_STELLA_F_CPP_CHANGE_CASE_MEMO_TABLE_000.surrogateValue));
}
memoizedEntry000 = MruMemoizationTable.lookupMruMemoizedValue(((MruMemoizationTable)(memoTable000)), symbol, caseconvention, ((Module)(Stella.$MODULE$.get())), Stella.MEMOIZED_NULL_VALUE, -1);
memoizedValue000 = memoizedEntry000.value;
}
if (memoizedValue000 != null) {
if (memoizedValue000 == Stella.MEMOIZED_NULL_VALUE) {
memoizedValue000 = null;
}
}
else {
memoizedValue000 = StringWrapper.wrapString(GeneralizedSymbol.helpCppChangeCase(symbol, caseconvention));
if (Stella.$MEMOIZATION_ENABLEDp$) {
memoizedEntry000.value = ((memoizedValue000 == null) ? Stella.MEMOIZED_NULL_VALUE : memoizedValue000);
}
}
{ StringWrapper value000 = ((StringWrapper)(memoizedValue000));
return (value000.wrapperValue);
}
}
} |
35dfb5a9-401f-4c5d-92b8-bd07391a7cd4 | 9 | public void validarIniciado(String dataInicial, String horaInicial) throws NumberFormatException {
limpaCamposCasoAberto();
String dtHoraFinalLote = retornaUltimaHoraFinalLoteLancado(jTJob.getText().trim(), Integer.parseInt(jTOperacao.getText()));
jFTDataFinalLote.setText("");
if(tempoPadrao){
salvarLote();
this.setVisible(false);
if(acessoCodBarras){
atualizar.doClick();
}
}else{
if (Validacoes.validaFormatoHora(jFTHoraInicio.getText(), jFTHoraInicio)
&& Validacoes.validaFormatoData(jFTInicioLote.getText(), jFTInicioLote) && validaCamposIniciado() && validaHoraInicialLoteIniciado(dtHoraFinalLote, dataInicial, horaInicial) && validarDecimalTripulacao(jFTQtdFuncionarios.getText().trim()) && validaMaxTripulacaoPermitida(Double.parseDouble(jFTQtdFuncionarios.getText().trim().replace(",", ".")))) {
salvarLote();
timer.start();
this.setVisible(false);
if (acessoCodBarras) {
atualizar.doClick();
}
}
}
} |
3dfce4e4-2331-4d22-a0d5-c34f44642c26 | 6 | public static List<Employee> execQueryEmployees (String query) {
Statement statement = null;
Connection dbConnection = null;
ResultSet rs = null;
List<Employee> emp = new ArrayList<Employee>();
try {
dbConnection = getDBConnection();
statement = dbConnection.createStatement();
rs = statement.executeQuery(query);
while (rs.next()){
Employee employee = new Employee();
employee.setIdPerson(rs.getInt("IDPERSON"));
employee.setName(rs.getString("NAME"));
employee.setFamily(rs.getString("FAMILY"));
employee.setEmail(rs.getString("EMAIL"));
emp.add(employee);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (dbConnection != null) {
try {
dbConnection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
return emp;
} |
fc9601bf-3ab2-4156-9f61-ba4d43f4e4c5 | 2 | private void expand(double[] array, int lay) {
int k = 0;
for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j < HEIGHT; j++) {
yCbCr[i][j][lay] = array[k++];
}
}
} |
a8a40280-801f-4172-964c-914757366537 | 6 | * @param localP
* @return Cons
*/
public static Cons callListUndefinedRelations(Module module, boolean localP) {
{ Cons undefined = Stella.NIL;
Logic.finalizeObjects();
{ Stella_Object term = null;
Iterator iter000 = Logic.allNamedTerms(module, localP);
while (iter000.nextP()) {
term = iter000.value;
{ Surrogate testValue000 = Stella_Object.safePrimaryType(term);
if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_NAMED_DESCRIPTION)) {
{ NamedDescription term000 = ((NamedDescription)(term));
if (!NamedDescription.definedRelationP(term000)) {
undefined = Cons.cons(term000, undefined);
}
}
}
else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_LOGIC_OBJECT)) {
{ LogicObject term000 = ((LogicObject)(term));
{ Object old$Module$000 = Stella.$MODULE$.get();
Object old$Context$000 = Stella.$CONTEXT$.get();
try {
Native.setSpecial(Stella.$MODULE$, ((module == null) ? term000.homeModule() : module));
Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
if (Logic.applyCachedAsk(Cons.cons(Logic.SYM_LOGIC_pX, Stella.NIL), Cons.list$(Cons.cons(Logic.SYM_PL_KERNEL_KB_RELATION, Cons.cons(Logic.SYM_LOGIC_pX, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.consList(Cons.cons(term000, Stella.NIL)), Cons.consList(Stella.NIL), Logic.SYM_LOGIC_F_CALL_LIST_UNDEFINED_RELATIONS_QUERY_000, new Object[1])) {
undefined = Cons.cons(term000, undefined);
}
} finally {
Stella.$CONTEXT$.set(old$Context$000);
Stella.$MODULE$.set(old$Module$000);
}
}
}
}
else {
}
}
}
}
return (undefined);
}
} |
613f865e-bbda-473a-bcee-ddda6ff704c3 | 5 | private void alertOf(String message, byte type)
{
messageLabel.setText(message);
messageScrollPane.getHorizontalScrollBar().setValue(0);
switch (type)
{
default:
case PLAIN_MES:
messageIconLabel.setIcon(null);
break;
case INFO_MES:
messageIconLabel.setIcon(infoIcon16);
break;
case QUESTION_MES:
messageIconLabel.setIcon(questionIcon16);
break;
case WARN_MES:
messageIconLabel.setIcon(warningIcon16);
break;
case CRIT_MES:
messageIconLabel.setIcon(errorIcon16);
CompAction.flash(this, true);
break;
}
} |
5677ade3-03b9-4ef1-87fd-56052f9b71b3 | 3 | @Override
public int hashCode() {
int hash = 7;
hash = 13 * hash + (this.varname != null ? this.varname.hashCode() : 0);
hash = 13 * hash + (this.value != null ? this.value.hashCode() : 0);
hash = 13 * hash + (this.inQuotes ? 1 : 0);
return hash;
} |
6df5ed1b-9d6c-4907-bf22-aad7c0c7e2e9 | 7 | private ArrayList<Node> getValidSurroundingNodes(Node n) {
ArrayList<Point> tempArrayList = new ArrayList<Point>();
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
if (!((x == 0) && (y == 0))) {
tempArrayList.add(new Point(n.x + x, n.y + y));
}
}
}
// now we check to see if any of these isn't white on the mask.
// System.out.println(tempArrayList.size());
ArrayList<Node> newList = new ArrayList<Node>();
Node nextItem;
for (int i = 0; i < tempArrayList.size(); i++) {
nextItem = new Node(tempArrayList.get(i), n);
//System.out.println(nextItem);
if ((onScreen(nextItem.x, nextItem.y)) && mask.getRGB(nextItem.x, nextItem.y) == Color.WHITE.getRGB()) {
newList.add(nextItem);
}
}
//System.out.println(newList.size());
return newList;
} |
8c6c208f-4338-4517-94ad-cda8af7ac5ff | 0 | public String getTexte() {
return texteRech;
} |
c50145b6-8f22-4f07-8f40-c5d5d3f09693 | 2 | public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
setText(value.toString());
if (index % 2 == 0) {
setBackground(new Color(155,215,231));
} else
setBackground(new Color(162,232,217));
if (isSelected) {
setBackground(new Color(166,166,166));
}
return this;
} |
22ebaafb-5c32-4741-80bc-2d881f179ab3 | 3 | public static final boolean isValid(String artifactType) {
for (int i = 0; i < artifactType.length(); i++) {
char c = artifactType.charAt(i);
if (!(Character.isLetter(c) || Character.isDigit(c))) {
return false;
}
}
return true;
} |
fcd8b9e3-bca2-40f3-be55-2096f4547be0 | 4 | public int SearchEndString(String TargetString, int CharNumStart, char EndStringChar) {
int FileTextPointer = 0;
try {
FileTextPointer = CharNumStart;
while (true) {
FileTextPointer = TargetString.indexOf(EndStringChar, FileTextPointer + 1);
if (FileTextPointer > 0) {
if (TargetString.charAt(FileTextPointer - 1) != '\\') {
break;
}
} else {
break;
}
}
} catch (Exception e) {
e.printStackTrace();
return FileTextPointer;
}
return FileTextPointer;
} |
28884efb-0996-47e6-9c48-03ed31c62af5 | 1 | protected void appendLabel(final Label l) {
String name = (String) labelNames.get(l);
if (name == null) {
name = "L" + labelNames.size();
labelNames.put(l, name);
}
buf.append(name);
} |
7be9029a-af80-42d8-81d2-7d3428f1ff0e | 9 | private node maxValue(node localHead, double alpha, double beta) {
ArrayList<node> ch = localHead.getChildren();
double temp = -100;
//terminating state
if (localHead.getValue() == 5 || localHead.getValue() == -5) {
return localHead;
}
//leaf node
if (ch.size() < 1) {
return localHead;
}
node ret = null;
for (int i = 0; i < ch.size(); i++) {
if (temp < minValue(ch.get(i), alpha, beta).getValue()) {
ret = ch.get(i);
temp = ret.getValue();
}
if (temp >= beta) {
for (int j = 0; j < ch.size(); j++) {
if (j != i && ch.get(j).getValue() != 0) {
ch.get(j).prunned = true;
//System.out.println("prunned");
}
}
return ret;
}
alpha = Math.max(alpha, temp);
}
return ret;
} |
2705b7a5-7c93-444c-85b0-71f62f124b03 | 6 | public static int[] kMinst(int[] a, int k){
int n = a.length; // tabellens lengde
if (k < 1|| k > n){
// Tester at k er minst 1 og ikke lengre enn lengden på array a.
throw new IllegalArgumentException
("Valgte antall minimums verdier samsvarer ikke med lengden på"
+ "talliste eller er 0");
}
int[] verdier = new int[k]; //Tabellen siste tall = k-1
for (int i = 0; i < verdier.length; i++){
verdier[i]=a[i];
}
Arrays.sort(verdier);
for (int j = k; j < a.length; j++){
//Første for velger første a verdi
for (int i = 0; i<verdier.length; i++){
//Andre for velger fra "verdier"
if(a[j]<verdier[i]){
verdier[--k]=a[j];
Arrays.sort(verdier);
break;
}
}
}
return verdier;
}//kMinst |
b32439eb-00c7-4fb6-ad22-d7d39e0e1666 | 4 | private Object handleCopr(Object tos) {
if ((tos instanceof Header && ((Header)tos).getCopyright() == null) ||
(tos instanceof GeneratorData && ((GeneratorData)tos).getCopyright() == null)) {
return new FieldRef(tos, "Copyright");
}
return null;
} |
f4d6e451-8862-41ac-96be-f70f78ba06a5 | 5 | private int findNextFarthestPoint(Matrix features
, Set<Integer> farthestPoints) {
int nextFarthestPoint = -1;
double max = 0;
List<Double> distances = new ArrayList<Double>();
for (int i = 0; i < features.rows(); i++) {
if (!farthestPoints.contains(i)) {
distances.clear();
double[] current = features.row(i);
for (int point : farthestPoints) {
distances.add(getEuclidDistance(current
, features.row(point)
, features));
}
double totalDistance = 0;
for (double distance : distances) {
totalDistance += distance;
}
if (totalDistance > max) {
totalDistance = max;
nextFarthestPoint = i;
}
}
}
return nextFarthestPoint;
} |
5023521e-7792-4d24-acc8-9d69a039d4fa | 2 | public static String md5(String s) {
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] array = md.digest(s.getBytes());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; ++i) {
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
}
return sb.toString();
} catch (java.security.NoSuchAlgorithmException e) {
}
return null;
} |
510c9df9-41b0-4b7d-b8bb-023f666f00af | 0 | public void run() {
movingObject.run();
} |
b30fdbfd-f788-46c5-91de-c47ab3ec672e | 8 | public void run() {
Selector selector = SocketIoProcessor.this.selector;
for (;;) {
try {
int nKeys = selector.select(1000);
doAddNew();
doUpdateTrafficMask();
if (nKeys > 0) {
process(selector.selectedKeys());
}
doFlush();
doRemove();
notifyIdleness();
if (selector.keys().isEmpty()) {
synchronized (lock) {
if (selector.keys().isEmpty()
&& newSessions.isEmpty()) {
worker = null;
try {
selector.close();
} catch (IOException e) {
ExceptionMonitor.getInstance()
.exceptionCaught(e);
} finally {
selector = null;
}
break;
}
}
}
} catch (Throwable t) {
ExceptionMonitor.getInstance().exceptionCaught(t);
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
ExceptionMonitor.getInstance().exceptionCaught(e1);
}
}
}
} |
c04b15f3-b181-4bfc-a4bb-944ff1a639f3 | 8 | public static void insertAllLocationTypes(){
boolean[][] activityTypes = new boolean[numLocations+1][9];
try {
Connection con = dbConnect();
PreparedStatement getActivity = con.prepareStatement(
"SELECT COUNT(*) FROM "+actTbl+" WHERE locationID = ? AND purpose = ?");
for (int location=1; location <= numLocations; location++){
for (int type=0; type < 9; type++){
getActivity.setInt(1, location);
getActivity.setInt(2, type);
ResultSet activityQ = getActivity.executeQuery();
activityQ.first();
int numMatches = activityQ.getInt(1);
if (numMatches > 0) activityTypes[location][type] = true;
else activityTypes[location][type] = false;
}
}
PreparedStatement setType = con.prepareStatement(
"UPDATE "+locTbl+" SET type = ? WHERE locationID = ?");
for (int location=1; location <= numLocations; location++){
setType.setInt(2, location);
String typeValue = "'";
for (int type=0; type < 9; type++){
if (activityTypes[location][type])
typeValue += activityTypeNames[type] + ",";
}
if (typeValue.length() > 1) {
typeValue = typeValue.substring(0, typeValue.length()-1) + "'";
setType.setString(1, typeValue);
System.out.println(location+"\t"+typeValue);
Statement st = con.createStatement();
st.executeUpdate(
"UPDATE "+locTbl+" SET type="+typeValue+" WHERE locationID="+location);
}
//else typeValue = "''";
}
setType.executeBatch();
con.close();
} catch (Exception e){
System.out.println(e);
}
} |
03786700-8ff4-446b-bc1e-fce95874f98b | 0 | public String getSenha() {
return senha;
} |
07be9a97-68a1-48f6-a695-ac10b676219f | 0 | public boolean isDestroyed() {
return solidObject.isDestroyed();
} |
eb173672-3e34-47de-bc96-ae529e27b654 | 7 | public void setCellInfo(int x, int y) {
//get the grid from operator
Grid grid = request.operator.getGrid();
Point p = new Point(x,y);
int depth = 0;
//strings to be displayed
String owner, oil, gas, layers, rocktype;
//if the grid location exists (not null)
if(grid.exists(p)) {
//get the owner name at p
owner = grid.getOwner(p);
//if the string is null or empty, display "Not Owned."
if (owner == null || owner.equals("")) {
owner = "Not Owned.";
}
//get the location of the top layer for seismic and rocktype
while((grid.layerExists(p,depth) == false)
&& depth < grid.getNumLayers())
depth++;
//if seismic data exists, display all of it, else display the top
if(grid.seismicExists(p)) {
//get the layer (seismic) array at p
Integer[] layersA = grid.getLayerArray(p);
layers = grid.removeEmptyFromArray(p,layersA);
} else {
layers = grid.getLayer(p,depth) + "";
}
//if p has been drilled, display all info, else display only the top rock.
if(grid.isDrilled(p)) {
//get the rock type array at p
LithologicType[] rocktypeA = grid.getRockArray(p);
String[] rocks = LithologicType.toArrayString(rocktypeA);
rocktype = grid.removeEmptyFromArray(p,rocks);
//get the oil rate array at p
Integer[] oilA = grid.getOilArray(p);
oil = grid.removeEmptyFromArray(p, oilA);
//get the gas rate array at p
Integer[] gasA = grid.getGasArray(p);
gas = grid.removeEmptyFromArray(p,gasA);
} else {
oil = gas = "No Information.";
rocktype = grid.getRock(p, depth).getShortName();
}
//if the gird location does not exist
} else {
owner = "Not Owned."; //If the cell does not exist it says not owned
oil = gas = layers = rocktype = "No Information."; //NO INFO FOR YOU!
}
request.setCellInfo(owner, oil, gas, layers, rocktype); //sets all of the data inside of requests
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.