method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
07e45e7c-f592-4ecc-9624-df5df7bd1028 | 4 | public double getMaxWeightedSum(){
/*
int[][][] weights = new int[][][] {
new int[][]{
new int[] { 8, 16, 32, 64},
new int[] { 4 , 8 , 16 , 32},
new int[] { 2 , 4 , 8 , 16},
new int[] { 1 , 2 , 4 , 8}
},
new int[][]{
new int[] { 64, 32, 16... |
8a7c180c-c4fc-4773-8bf0-ddcf7c3e80b3 | 6 | public void paint(Graphics g){
//iniciliazn el DoubleBuffer
if(imaImagenJFrame == null) {
imaImagenJFrame = createImage (this.getSize().width,
this.getSize().height);
graGraficaJFrame = imaImagenJFrame.getGraphics();
}
// creo imagen p... |
f5223c9a-33be-4117-8688-0ebe525148c6 | 1 | public List<SoftwareSystem> generateAlternativesEP() {
if (project.getDeploymentAlternatives().size()==0)
generateAllDeploymentAlternatives();
generateHardwareSetAlternativesEP();
generateHardwareSystemAlternativesEP();
return generateSystemsEP();
} |
f8e87562-a709-4413-816c-2d72c76a9ea8 | 8 | public void firstPassingNode(Element e) {
if(e.getLocalName().equals(StringDefinitions.DIAGRAMS_STRING)) {
return;
}
else if(e.getLocalName().equals(StringDefinitions.CLASS_STRING)) {
handleClass(e);
}
else if (e.getLocalName().equals(StringDefinitions.ASSOCIATION_STRING)) {
handleAssociation(e);
... |
b536be36-a77b-4b3e-878a-b06f75196711 | 1 | void fireWait(ComponentAccess w) {
if (shouldFire) {
fire(Type.WAITING, new ComponentEvent(c, w.getComponent()));
}
} |
a744ed24-aef7-44fc-973b-be7c8529202a | 8 | public static void beenden() throws IOException {
final JFrame Beenden = new JFrame("Ein Frame zum Schließen");
Properties spielstand = loadProperties("spielstand.txt");
Beenden.setTitle("Spiel beenden");
Object[] options = {"Speichern", "Beenden", "Abbrechen"};
int beenden = JOptionPane.sh... |
71c2883b-51f8-417a-9faa-419e0edae406 | 3 | @Override
public Object getValueAt(int i, int i1) {
Object devuelto = null;
switch (i1) {
case 0:
devuelto = datos.get(i).getTitulo();
break;
case 1:
devuelto = datos.get(i).getFecha_Limite();
... |
8eb3ca76-f413-44d7-842e-8c453138cbbe | 1 | public void testGet_DateTimeField() {
DateMidnight test = new DateMidnight();
assertEquals(1, test.get(ISO_DEFAULT.era()));
assertEquals(20, test.get(ISO_DEFAULT.centuryOfEra()));
assertEquals(2, test.get(ISO_DEFAULT.yearOfCentury()));
assertEquals(2002, test.get(ISO_DEFAULT.year... |
b4a2151f-e55d-47e0-88aa-e8543bed6059 | 6 | public List<List<Integer>> fourSum(int[] num, int target) {
List<List<Integer>> result = new ArrayList<List<Integer>>();
Arrays.sort(num);
int length = num.length;
for (int i=0;i < length-3 ;i++ ){
for (int j =i+1; j < length-2 ;j++ ){
for (int m = j+1, n = le... |
ea5807fe-d104-4423-b803-4311ce16d9d6 | 1 | public void render() {
Renderer.get().draw(background);
Iterator<RenderObject> it = renderableActors.iterator();
while(it.hasNext()) {
RenderObject ro = it.next();
Renderer.get().draw(ro);
}
} |
0421fc24-fba8-4238-a1b1-583f6d10a5f8 | 1 | public Object serialize(YAML yamlAnnotation, Object containingObject, java.lang.reflect.Method getterMethod, java.lang.reflect.Field field, String yamlFieldName, Object yamlFieldValue) {
if ("REMOVEME".equals(yamlFieldValue)) {
return null;
} else {
return "MODIFIED";
}
} |
16126a18-b541-433a-97d6-ab7b4ddb5247 | 1 | @Override
public String toString() {
String cacheObjectStr = "NULL";
if (cacheObject != null) {
cacheObjectStr = cacheObject.toString();
}
return "实际缓存对象[" + cacheObjectStr + "],版本[" + version + "]";
} |
fbb023f4-bd74-41a3-b47c-4d69b3e04b3f | 7 | @Override
public void actionPerformed(ActionEvent e) {
if("10".equals(e.getActionCommand())){
m.setAsteroidAmount(10);
}
if("20".equals(e.getActionCommand())){
m.setAsteroidAmount(20);
}
if("30".equals(e.getActionCommand())){
m.setAsteroidA... |
9d5a210a-6c4d-42f5-8e48-d2fd8f2390bf | 5 | public static void update(){
for(int i = 0; i<4; i++){
if(i==0)prev[KeyEvent.VK_LEFT] = pressed[KeyEvent.VK_LEFT];
if(i==1)prev[KeyEvent.VK_RIGHT] = pressed[KeyEvent.VK_RIGHT];
if(i==2)prev[KeyEvent.VK_UP] = pressed[KeyEvent.VK_UP];
if(i==3)prev[KeyEvent.VK_DOWN] = pressed[KeyEvent.VK_DOWN];
}
} |
5406a4ac-d90d-4a63-b9cf-af8dac22bcb0 | 4 | public String generate() {
String error = "No errors.";
if (details)
System.out.println("Heightmap flags: PRODUCE="+ioflags.PRODUCE+", SAVE="+ioflags.SAVE+", LOAD="+ioflags.LOAD);
if (Utils.flagsCheck(ioflags) != 0) {
System.out.println("ERROR: IOFlags object is corrupted, error: "+Utils.flagsCheck(io... |
be23943b-3db5-4cc5-96c4-436750e54f9a | 8 | public void decisionMaking (){
Scanner sc = new Scanner(System.in);
//taking 3 inputs
System.out.println("Enter the first number");
int number1 = sc.nextInt();
System.out.println("Enter the Second number");
int number2 = sc.nextInt();
System.out.println("Enter ... |
93d2a0d3-98aa-4fa4-99e9-bb8d3c2e9808 | 6 | public boolean isInDataBase(AlumnoCartaCompromisoDTO alumnocp) {
Connection con = null;
PreparedStatement pst = null;
String sql = null;
ResultSet rs = null;
int bandera = 0;
// Leemos el semestre que termina del archivo de configuración
// config.properties
ResourceBundle bundle = ResourceBundle.getBun... |
c4801c96-1b8f-4dae-9c7b-5370fe8be4a2 | 5 | public byte[] getResponseFromUrl(String urlStr) throws Exception
{
URL url = new URL(urlStr);
int retries = 6;
int msWait = 200;
while(retries > 0){
InputStream responseStream = null;
try {
URLConnection connection = url.openConnection(... |
b14f12c0-42b2-4a12-983b-188b5a87fd77 | 1 | public static void main(String[] args) throws Exception {
// if (args.length != 2) {
// System.err.println("Usage: MaxTemperature <input path> <output path>");
// System.exit(-1);
// }
String input = "/Users/aaronwong/Documents/workspace_java/DataPreprocessing/src/data/out_countries.list";
S... |
47b375a9-3ee0-4985-bb36-8e336f61c7de | 2 | @Override
public void salvar(Secao secao, Evento evento) {
try {
conn = ConnectionFactory.getConnection();
String sql = "INSERT INTO secao (id, nome, valor, idevento) "
+ "VALUES ((SELECT NVL(MAX(id),0)+1 FROM secao), ?, ?, (SELECT id FROM evento WHERE nome = ... |
fcea42e8-a42e-4196-a0c4-f950d2f53bb0 | 1 | private Object toValue(String name, double[] vals, Map<String, Object> parameter) {
Object orig = parameter.get(name);
if (orig.toString().indexOf('{') > -1) {
// this is an array (hopefully 1dim)
return Conversions.convert(vals, String.class);
} else {
return... |
0387ae1f-f4cd-4027-b8c5-942edb170c8c | 8 | private void setAnchorPointForRectangularShape(int i, float x, float y, float w, float h) {
switch (i) {
case UPPER_LEFT:
anchorPoint.setLocation(x + w, y + h);
break;
case UPPER_RIGHT:
anchorPoint.setLocation(x, y + h);
break;
case LOWER_RIGHT:
anchorPoint.setLocation(x, y);
break;
case LOW... |
096e8e21-a7c2-4a7b-aab7-3adf69d48888 | 7 | private JSONWriter append(String s) throws JSONException {
if (s == null) {
throw new JSONException("Null pointer");
}
if (this.mode == 'o' || this.mode == 'a') {
try {
if (this.comma && this.mode == 'a') {
this.writer.write(',');
... |
71ba338f-5689-4138-8890-8007c59cce09 | 3 | public void crowdControlled(int debuff){
if (debuff == EARTH){
entombed = true;
}
else if (debuff == WATER){
slowed = true;
}
else if (debuff == WIND){
knockedback = true;
}
else{
stunned = true;
}
} |
62343059-5139-4c2a-969b-e865b1fca0cf | 2 | public double[] standardizedItemVariances(){
if(!this.dataPreprocessed)this.preprocessData();
if(!this.variancesCalculated)this.meansAndVariances();
return this.standardizedItemVariances;
} |
d9e0eced-d8cb-4278-894e-eb381de8e9f6 | 1 | private static void createAndShowGUI(int nbugs) {
JFrame f = new JFrame("Swarm Demo");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
double dt = 0.01;
int ddt = 20;
if (nbugs > 20) {
dt = 0.1;
ddt = 2;
}
Playfield p = new Playfield(nbug... |
43425d6d-cb83-484a-ad24-f404311c66d7 | 5 | @Override
public void run() {
gui = new RecvGUI();
try {
s = new Socket( srcaddr, 9988 );
DataInputStream in = new DataInputStream( s.getInputStream() );
DataOutputStream out = new DataOutputStream( s.getOutputStream() );
String filename = in.readUTF();
int filesize = in.readInt();
System.out.pri... |
fa580e32-0587-427c-b2d8-88d09e2ba991 | 6 | public void func_4157_a(double[] var1, double var2, double var4, int var6, int var7, double var8, double var10, double var12) {
int var14 = 0;
for(int var15 = 0; var15 < var6; ++var15) {
double var16 = (var2 + (double)var15) * var8 + this.field_4292_a;
for(int var18 = 0; var18 < var7; ++... |
72010b87-84f2-44fa-83bd-5f29bff57453 | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Menu)) {
return false;
}
Menu other = (Menu) object;
if ((this.id == null && other.id != null) || (this.id != n... |
eb56ee46-b3df-44d9-abbb-5a4908af60fa | 2 | private String getNextWord(int index) {
int start = indexOfNextNameChar(index);
if (start == -1) {
return null;
}
int end = indexOfNextNonNameChar(start);
if (end == -1) {
end = chars.length;
}
int length = end - start;
char[] word = new char[length];
System.arraycopy(chars, start, word, 0, le... |
d706a2b9-97b8-4855-9d3c-60a161c14b41 | 6 | public static HashMap<String,HitScores> getTopHitsFilteredByPercentIdentityAtMinLength(
String filepath, int minLength) throws Exception
{
//Query id, Subject id, % identity, alignment length
HashMap<String, HitScores> map= new HashMap<String, HitScores>();
BufferedReader reader = new BufferedReader(new... |
cb384269-1a72-4883-96b1-466a28f6f1b1 | 0 | public void earnBonus() {
int luckyEmployee=numGen2.nextInt(6);
System.out.println("Employee "+luckyEmployee+" won the bonus!");
employees[luckyEmployee].earnBonus();
} |
7f90ea00-de9d-4888-9dd1-fd00fe5237d4 | 0 | public int wepATK() {
return inventory.getItem(0).getATK();
} |
c327b95c-29bb-457a-a9df-575a0fe61cd1 | 3 | private void findNext () {
while (ts.isEmpty () && !toVisit.isEmpty ()) {
Node<T> n = toVisit.remove (toVisit.size () - 1);
visitedNodes++;
n.expand (mbr, converter, ts, toVisit);
}
if (ts.isEmpty ()) {
next = null;
} else {
next = ts.remove (ts.size () - 1);
dataNodesVisited++;
}
... |
d637b66e-1ea8-4002-b5b0-4a58ee747c15 | 3 | public void run() {
StringBuilder s = new StringBuilder();
for (int i = 0; i < FINISH_LINE; i++)
s.append("="); // The fence on the racetrack
print(s);
for (Horse horse : horses)
print(horse.tracks());
for (Horse horse : horses)
if (horse.getStrides() >= FINISH_LINE) {
print(horse + "won!... |
3b3c2cb1-5c7a-4f03-b8af-7ff1b0a1651b | 2 | public void setLevelSize(int width, int height)
{
if(tileGrid == null)
{
gridWidth = width;
gridHeight = height;
tileGrid = new Tile[height][width];
for(int i = 0; i < height; i++)
{
tileGrid[i] = new Tile[width];
}
}
} |
35b12f17-1400-4585-898d-7d1bcc5ec8d9 | 9 | public WorldPanel(World world) {
this.model = world;
this.worldMap = model.getWorldMap();
JLabel label;
BufferedImage gold = null;
BufferedImage pit = null;
BufferedImage wumpus = null;
// BufferedImage hunter = null;
// BufferedImage empty = null;
try {
gold = ImageIO.rea... |
dd48c5fb-ef09-4299-8f74-bea9597e5bda | 6 | public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page ... |
ca27809e-39c8-48ed-ac7d-cf153c50491b | 3 | private void detectedFile(DetectionType type, File file) {
String name = file.getPath();
if(name.endsWith(".xml")) {
name = name.substring(0, name.lastIndexOf('.'));
name = name.substring(name.lastIndexOf(File.separator) + 1);
if(type == DetectionType.ORIGINAL || type == DetectionType.CREATE) {
this.co... |
2dc3ecb2-c501-42f0-80d8-e4bd0cc502a9 | 3 | private int getNumberBySlot(int slot) {
slot--; // skip this parameter (not an outer value)
for (int i = 0; slot >= 0 && i < headCount; i++) {
if (slot == 0)
return i;
slot -= head[i].getType().stackSize();
}
return -1;
} |
f3c726c4-4b24-4d2d-af2e-712f867747cf | 2 | public static void main(String[] args) {
System.out.println("Please enter two integers: ");
int a = inputInt();
int b = inputInt();
if (a >= 0 && b >= 0) {
System.out.println("Both are positive or zero.");
} else {
System.out.println("One or both are negative.");
}
} |
7e2eb9fc-f858-4d5e-a4eb-d66a951a18b3 | 1 | public static boolean loadDB(ResultSet res, String userName) {
try {
PlayerData.userName = userName;
coins = res.getInt("Coins");
playtime = res.getLong("Playtime");
lck_lvl = res.getString("lck_lvl").getBytes();
lck_bg = res.getString("lck_bg").getBytes();
lck_chr = res.getString("lck_chr").getByte... |
5f5e8778-6b2f-4b82-a528-ef7a77d7be56 | 6 | public static void main(String args[]) {
if (args.length != 1) {
System.out.println("Usage: CreateArffFromFragmentStats prop.properties");
return;
}
PropertyHandler propHandler = new PropertyHandler(requiredProps);
Properties properties;
FileInputStream is;
FileOutputStream os;
... |
6122011e-0d01-4338-a5a0-b0dad94e98b0 | 6 | @Test
public void testProfileCrudUsingToken() {
Gateway beanstream = new Gateway("v1", 300200578,
"4BaD82D9197b4cc4b70a221911eE9f70", // payments API passcode
"D97D3BE1EE964A6193D17A571D9FBC80", // profiles API passcode
"4e6Ff318bee64EA391609de89aD4CF5d");// r... |
fefe1f29-ada5-4d45-b937-20b2e8686033 | 2 | public BTPosition<T> getMax(BTPosition<T> root) {
if (root == null)
return null;
BTPosition<T> current = root;
while (current.getRight() != null) {
current = current.getRight();
}
return current;
} |
fbfe72fe-7e7c-4512-9432-f05a295e6123 | 1 | private void updateRollOver() {
boolean wasBorderShown = mShowBorder;
Point location = MouseInfo.getPointerInfo().getLocation();
UIUtilities.convertPointFromScreen(location, this);
mShowBorder = isOver(location.x, location.y);
if (wasBorderShown != mShowBorder) {
repaint();
}
} |
fab13e08-f377-4109-bf59-b380a94e74b9 | 6 | public static int divide(int dividend, int divisor) {
long p = Math.abs((long)dividend);
long q = Math.abs((long)divisor);
int ret = 0;
while (p >= q) {
int counter = 0;
while (p >= (q << counter)) {
counter++;
}
re... |
44e8f312-4faf-4742-a9fe-5f52dfc9633a | 0 | protected void threadStopped() {
// do nothing
} |
aa0ac3b5-2102-4e10-a98f-226b6932d7a6 | 8 | private void install(String[] commandString, Player player) throws CommandException {
if (commandString.length > 1) {
String componentName = "";
for (int i = 1; i < commandString.length; i++) {
componentName += " " + commandString[i];
}
componentNa... |
d22e457d-1e33-4d3a-a837-d6f0faac34bb | 2 | public void VerificaColisao(Polygon colisor, String tag) {
for (Point vertice : vertices) {
Point ponto = new Point(vertice);
if (colisor.contains(ponto)) {
this.tag = tag;
delete = true;
}
}
} |
81cd123f-ba72-4ecf-9798-bb1e92fea8cb | 7 | public void run() {
String nick = null;
try {
String s = null;
String pm = null;
out.write("User connected to port: " + sock.getPort());
out.newLine();
out.flush();
out.write("Enter desired nickname: ... |
7d2cac43-f2e8-4a23-a660-c818d596603a | 1 | public static void isTrue(boolean expression, String message) {
if (!expression) {
throw new IllegalArgumentException(message);
}
} |
5344ca7c-970f-46b8-b1b0-dc0e657b5f67 | 9 | private void readAndDecompress() throws IOException {
// Read the length of the compressed block
int ch1 = in.read();
int ch2 = in.read();
int ch3 = in.read();
int ch4 = in.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
inLength = (... |
ced65bb5-064e-4dc1-9e8f-d840b6ff3130 | 1 | public void update(Observable o, Object arg) {
AnalysePanel p = Main.analyseFrame.getCurrentPanel();
getAction(Constantes.REDO).setEnabled(p.getRedoEnabled());
getAction(Constantes.UNDO).setEnabled(p.getUndoEnabled());
getAction(Constantes.CUT).setEnabled(p.getCopyEnabled() && p.getPasteEnabled());
getActio... |
ad2b8e50-fc4e-48b8-9d72-2a2ba4b3ec8a | 0 | protected void displayMultipleRunPane(Environment env){
MultipleSimulateAction act = new MultipleSimulateAction((Automaton)myObjects.get(0),env);
act.performAction(env);
} |
4df211dd-d56b-47e9-a763-39bcde6a2eb1 | 0 | @Override
public void actionPerformed(ActionEvent e) {
openOutlinerDocument(getProtocol());
} |
1bd8436d-c4c5-4bad-8d25-29b3f2db926a | 3 | public static String dbFileChooser() {
Path path = null; // get the path where our jar file is executing
try {
path = Paths.get(MICE.class.getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (URISyntaxException e) {
e.getMessage();
}
JFil... |
0d7ec4a5-eaf6-4641-9a3a-5aaeae35cd74 | 8 | protected void process() throws IOException {
// INPUT file 1
BufferedReader bfr = new BufferedReader(new InputStreamReader(
new FileInputStream((String)file_input_old.getSelectedItem()), encoding_old.getSelectedItem().toString()));
Modifier myModifier = new RegexModifier(">", 0, "\t");
Reader modifyingRe... |
f3c33690-8106-47e4-9ff3-ec26f6c2335b | 7 | @Override
protected void drawInternalU(UGraphic ug, Area area, boolean withShadow) {
final StringBounder stringBounder = ug.getStringBounder();
final double textHeight = getTextHeight(stringBounder);
ug.getParam().setColor(getForegroundColor());
final double x2 = arrowWidth - 3;
if (getArrowConfiguration()... |
a3c9af48-cddd-430c-85a0-a0e19e978fc5 | 4 | public void itemStateChanged(ItemEvent e) {
//create a new font object.
Font font;
//if these are selected, do this code.
if(boldBox.isSelected() && italicBox.isSelected()){
font = new Font("Serif", Font.BOLD + Font.ITALIC, 14);
}
else if(italicBox.isSelected()){
font = new Font("Serif",... |
6c6aad36-f0b4-45b7-98eb-d5618e3c5be9 | 3 | public static double[][] toHomogeneousCoordinates(double[][] m) {
int mRows = m.length;
int mColumns = m[0].length;
double res[][] = new double[mRows + 1][mColumns + 1];
for (int i = 0; i < mRows; i++) {
for (int j = 0; j < mColumns; j++) {
res[i][j] = m[i][j];
}
res[i][mColumns] = 0;
}
for (in... |
a62d83ad-8662-43fb-b57b-6923cbad9a07 | 4 | public static Object decodeToObject( String encodedObject )
{
// Decode and gunzip if necessary
byte[] objBytes = decode( encodedObject );
java.io.ByteArrayInputStream bais = null;
java.io.ObjectInputStream ois = null;
Object obj = null;
try
{
bais = new java.io.ByteArrayInputStream( objBytes );
... |
ca7cf2df-f7f1-4a20-a3b3-b4b4e0d78f9b | 5 | private String read_block(char[][] ct)
{
//read the block horizontally
StringBuilder sb=new StringBuilder();
for(int i=0;i<ct[0].length;i+=period)
{
int end=i+period>ct[0].length?ct[0].length:i+period;
for(int j=0;j<ct.length;j++)
{
for(int k=i;k<end;k++)
{
if(ct[j][k]!='\0')
{
... |
5d5e1267-6048-4cea-9fad-e6523edc193a | 8 | @Override
public int getMetricInternal() {
// System.out.println("SW2");
do {
EflUtil.runToAddressNoLimit(0, 0, 0x374cf); // after SlotMachine_374fb
EflUtil.runToAddressNoLimit(0, 0, 0x374cc); // before SlotMachine_374fb
if (curGb.readMemory(0xcd3d) != 2) // wrong wheel
return 0;
// ... |
8f6f880c-8733-40ed-bf50-b0d08029a566 | 0 | public JSeparator getjSeparator1() {
return jSeparator1;
} |
11952ec2-231e-4309-b81c-2f6db3bfafc8 | 5 | public static void main (String[] args) throws java.lang.Exception {
if (args.length < 1) {
System.out.println("Usage: java -cp unscramble.jar Main <file names>");
return;
}
// The following string is the package's name, used as content unscrambling key
// Refer to refactored ScrambleReader code... here's... |
18cbf1a2-882b-4814-98d9-e577bd06fabf | 8 | protected void doSortWorker(ActorManager manager, int nest, List<Comparable> values, String id, PendingMerge pm) {
sleep(1000);
if (values.size() <= 1) {
DefaultMessage dm = new DefaultMessage("sortComplete", new Object[] { nest, values, id });
logger.info("send size complete %s(%d): %s", id, nest, values);
... |
4997251d-e6a3-4650-8531-e8a000f5d1aa | 8 | public void addUser(String username, String password)
throws DuplicateUserException, BadUsernameException, BadPasswordException{
if(username == null || username.length() == 0){
throw new BadUsernameException("Invalid username");
}
if(password == null || password.length() == 0){
throw new BadPasswordE... |
34dd9028-8eff-4d14-bed9-6cbd32e81ffa | 8 | private double getMagic(String word, int idx) {
double c;
switch (idx) {
case 0:
c = seahawks.containsKey(word) ? (double) seahawks.get(word) : 0.0;
return (c + 1.0) / (60.0 + seahawks.size());
case 1:
c = nfl.containsKey(word) ? (double) nfl.get(word) : 0.0;
return (c + 1.0) / (60.0 + nfl.size(... |
7bc7b327-9958-48ed-9049-8446d3337ea9 | 4 | public static int addMarks(int index, String value) {
if ((index < 0 && index > 9)
|| (Float.valueOf(value) < 0 && Float.valueOf(value) > 20))
return 0;
marks[index] = value;
return 1;
} |
fdb3a213-0ed4-492b-8777-b1f08f7705de | 3 | protected void initPool() {
if (!initialized) {
long start = System.currentTimeMillis();
for (int i = 0; i < initialSize; i++) {
queue.offer(create());
}
initialized = true;
if (LOG.isDebugEnabled()) {
LOG.debug(StringUtil.concatenateStrings(this.getClass().getSimpleName(), ".initPool: ",
... |
aa421135-8ea6-4792-81c3-d9b16f78ad23 | 5 | public static void password()
{
List<Employee> employee = ExtractEmployees.employee;
String password = "";
String tempPassword = null;
Scanner sc = new Scanner(System.in);
while (tempPassword == null)
{
System.out.print("Enter your password: ");
password = sc.nextLine();
if (password == null || ... |
74ecdb7d-be02-4e3a-872b-992851e56980 | 3 | public boolean put(Message message) throws DestinationClosedException {
boolean isSuccessful = super.put(message);
if (!isSuccessful) {
if (discardPolicy == MessageDiscardPolicy.DiscardOldest) {
// Until successful insert
while (!queue.offer(message)) {
queue.poll();
}
expiryUtil.scheduleFor... |
ce8ddc17-29f1-4c12-952a-7a1ded61ba1b | 6 | public void setCodes(byte[] codes) {
byte[] possible = supportedCodes();
List<Byte> newCodesList = new ArrayList<>(maxCodeCount());
int newCount = 0;
for (int i = 0; i < codes.length; i++) {
byte c = codes[i];
if (Arrays.binarySearch(possible, c) < 0) {
throw new IllegalArgumentException("Code " + co... |
d168cf96-6ff3-4f4e-8280-e6be57910889 | 0 | public void setEmployeeCant(int employeeCant) {
EmployeeCant = employeeCant;
} |
9fc440e3-2148-4556-9789-36c035d6f2fa | 0 | @Override
public void endSetup(Attributes atts) {} |
925fe425-7a64-41ae-b704-81fd556ed8b2 | 8 | private void runSpikingProblem(Evolution evo){
outputScreen.setText("");
int populationSize = Integer.parseInt(populationSizeField.getText());
int generations = Integer.parseInt(generationsField.getText());
SpikingNeuronProblem sn = (SpikingNeuronProblem) problem;
List<Individual... |
490e3b02-8300-4635-935a-14fed83a254e | 3 | @Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10f);
TileLoader loader = TileLoader.getInstance();
Tile[][] map = new Tile[3][3];
Material matone = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
Material mattwo = matone.clone()... |
d4d3dde5-5742-4d76-94b1-3f0a3e919b7d | 3 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
try{
if(!Helpers.isValidDouble(jTextField2.getText())){
JOptionPane.showMessageDialog(this, "Please enter valid number for amount", "Number Format Error", JOptionPane.ERROR... |
cdb3d168-b9c6-4834-b8a3-1e69eaaa914a | 3 | public Object dequeue() throws AskFromEmpty {
if (count > 0) {
QueueElement previous = head;
QueueElement current = head.next();
if (previous == searchMax()) {
head = head.next();
count--;
return previous.getValue();
... |
f13e7d07-f51e-4916-a0bf-62fb549d0ef0 | 7 | Poblacion recombine(Poblacion p)
{
Poblacion ret = new Poblacion(p.getSize());
if(p.getSize()%2!=0) {
System.err.println("El tamaño de la poblacion debe ser par");
System.exit(1);
}
int ham;
Genotipo uno, dos;
for(int i=0; i<p.getSize(); i += 2... |
a9002744-9e43-4ad1-a5ff-3a7cf80be6a4 | 0 | public void actionPerformed(ActionEvent e) {
requestFocusInWindow();
repaint();
} |
4116545e-7393-4a09-b6a4-f050099b1754 | 3 | public void Update(World world)
{
Intergrate(world);
Friction(world);
for(int i = 0;i< res.length;++i)
{
if(res[i] != null)
{
if(res[i].Quantity>100){res[i].Quantity = 100;}
}
}
} |
a9128b93-15bd-4ef6-b45d-1c95c6e7c051 | 6 | @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (null == obj) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
LinkDirectionCity eq = (LinkDirectionCity)obj;
if... |
35180eb6-64fa-460b-b9c6-88d70bb68b97 | 8 | @Override
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args)
{
if (!(sender instanceof Player))
{
sender.sendMessage("Commands are designed to be run by players only.");
return true;
}
Player player = (... |
5ee36b8b-6e0c-4adb-a3f1-e224026b55bd | 1 | @Override
public void startSetup(Attributes atts) {
int size = 10;
try {
size = Integer.parseInt(atts.getValue(A_SIZE));
} catch (NumberFormatException e) {}
JTextField component = new JTextField(size);
setComponent(component);
super.startSetup(atts);
component.addFocusListener(new TextFieldListener(c... |
a2d5761d-3472-445a-ad43-c97bc455cded | 1 | private static void PrinterOrder(List<Integer> list){
Iterator<Integer> it = list.iterator();
while(it.hasNext()){
System.out.print(it.next()+":");
}
} |
13a1e9f6-5ea6-44ff-a776-0fae5e53f66e | 2 | public void insertar(BeanProducto bean) {
if (!dao.buscar(bean) && dao.insertar(bean)) {
JOptionPane.showMessageDialog(null,
"Se ha agregado un nuevo producto", "Info", 1);
} else {
JOptionPane.showMessageDialog(null,
"El producto ya existe... |
e83f7d39-ff7e-44bb-9a8f-cd512af822ef | 8 | static public double erfc(double a) throws ArithmeticException {
double x, y, z, p, q;
double P[] = { 2.46196981473530512524E-10, 5.64189564831068821977E-1, 7.46321056442269912687E0,
4.86371970985681366614E1, 1.96520832956077098242E2, 5.26445194995477358631E2, 9.34528527171957607540E2,
1.027551886895157102... |
c8683c12-8070-47d5-9231-15edf595cc7e | 7 | public Object nextContent() throws JSONException {
char c;
StringBuffer sb;
do {
c = next();
} while (Character.isWhitespace(c));
if (c == 0) {
return null;
}
if (c == '<') {
return XML.LT;
}
sb = new Str... |
a3cd1cd3-bb75-4749-b965-6df080b5e54c | 7 | private void topStroke(Location loc, int size){
// If Size == 0 we are done.
// If Invalid, we can't move up any further anyway, so stop.
if(size == 0 || !grid.isValid(loc)) return;
Actor tmp = null;
int r = loc.getRow();
int c = loc.getCol();
for(int i = 0; i < size; i++){
Location rightLoc = ne... |
c0e4f9c9-8e6c-4d56-a15b-3341637b5dd5 | 5 | public double evaluate(double num1,String operator,double num2){
double result = 0;
if(0 == operator.compareTo("+")){
result = new Addition(num1, num2).operate();
}
if(0 == operator.compareTo("-")) {
result = new Substraction(num1, num2).operate();
}
... |
98b926df-e648-4f22-bddd-50e2bc4eed24 | 2 | private boolean pluginFile(String name) {
for (final File file : new File("plugins").listFiles()) {
if (file.getName().equals(name)) {
return true;
}
}
return false;
} |
a44435a1-0a8f-4a25-ba7a-b2abc4790d66 | 9 | public static int countFill(int[] landscape, int start) {
if (start >= landscape.length - 1) {
return 0;
}
int startIndex = start;
int endIndex = 0;
int startHeight = landscape[start], endHeight = 0;
for (int pos = start; pos < landscape.length; pos++) {
... |
0c5ecf6f-f779-405a-a26d-ac18707cc070 | 5 | public boolean send(String text) throws IOException {
if (!this.handshakeComplete) throw new NotYetConnectedException();
if (text == null) throw new NullPointerException("Cannot send 'null' data to a WebSocket.");
// Get 'text' into a WebSocket "frame" of bytes
byte[] textBytes = text.getBytes(UTF8_CHARSET);
... |
efbaef61-44fa-4e2d-b69c-5911e67fcff4 | 9 | public String[] processCommand(String[] splitLine) {
String[] command;
if (splitLine.length >= 1) {
switch (splitLine[0].toLowerCase()) {
case "quit":
command = new String[] { QUIT };
break;
case "help":
command = new String[] { HELP };
break;
case "step":
if (splitLine.leng... |
44a30879-531a-4ccd-afa5-3848fe45af16 | 2 | @Override
public void paintComponent(Graphics g2) {
Graphics2D g = (Graphics2D) g2;
Dimension originalSize = super.getSize();
Color above = new Color(66, 122, 241);
Color under = new Color(29, 82, 194);
if (isPressed) {
GradientPaint gradPaint = new GradientPaint(0, 0, above, 0, originalSize.height - 3,... |
746d2f98-3744-42db-a0e6-ee8ab6fe9d2e | 8 | private boolean needsMet(int meetLevel) {
if (personnel.residents().size() == 0) return false ;
if (meetLevel <= HoldingUpgrades.LEVEL_TENT ) return true ;
if (meetLevel > HoldingUpgrades.LEVEL_GUILDER) return false ;
final Object met = HoldingUpgrades.NEEDS_MET ;
return
HoldingUpgrades.ch... |
49f3a2f5-e822-4abe-a764-2383a094afa2 | 9 | public boolean projectionIsOnLine(Point point) {
double distance = rawDistanceToPoint(point);
Point normal = new Point(pA.getY() - pB.getY(), pA.getX() - pB.getX());
normal.divide(distance(normal, new Point(0, 0)));
Point pointOnLine = point.add(normal.multiply(distance))... |
75a7d872-217f-43fa-866f-02d04c46c7b1 | 6 | public void loadRegionDirectory(String dir) throws Exception{
ArrayList<Chunk> chunkslist = new ArrayList<Chunk>();
String[] files = (new File(dir)).list(new FilenameFilter(){
@Override
public boolean accept(File file, String filename) {
return filename.toLowerCase().endsWith(".mca");
}
});
System.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.