method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
4baca47b-e4d3-4abd-938a-093446ba08a9 | 4 | public void settip(String t) {
tooltip = t;
q2 = -1;
if (tooltip != null) {
try {
Matcher m = patt.matcher(tooltip);
while (m.find()) {
q2 = Integer.parseInt(m.group(1));
}
Matcher valm = pattVal.matcher(tooltip);
if (valm.find()) {
count_of_value = Double.parseDouble(valm.group(1... |
58920137-09c1-428e-8b70-afec987d56b7 | 2 | public void testGetFieldType() {
YearMonthDay test = new YearMonthDay(COPTIC_PARIS);
assertSame(DateTimeFieldType.year(), test.getFieldType(0));
assertSame(DateTimeFieldType.monthOfYear(), test.getFieldType(1));
assertSame(DateTimeFieldType.dayOfMonth(), test.getFieldType(2));
tr... |
f83d4905-c62e-4e6e-9b7c-cc0e346140eb | 7 | public void run() {
while (true) {
if (myDestinations.size() > 0) {
// System.out.println("About to visit floor");
int dir = getMyDirection();
if (dir == DIRECTION_UP || dir == DIRECTION_NEUTRAL) {
VisitFloor(myDestinations.first());
}
if (dir == DIRECTION_DOWN) {
VisitFloor(myDest... |
dc535998-de2f-47c5-9dc2-aeba35fe1f71 | 6 | @Override
public int awardPoints(boolean[] sv,int objectSize) {
if(objectSize>thresh){
for (boolean b : sv) {
if(b) return 0; //If any part is touching
}
return 1;
}
else{ //Tracker should catch it
int c = 0;
for (boolean b : sv) {
if(b) c++;
}
return c == objectSize ? 1 : 0;
}... |
d5136578-f1f5-49ae-9688-8b60ea8ab89a | 3 | private boolean interact(int x0, int y0, int x1, int y1) {
List<Entity> entities = level.getEntities(x0, y0, x1, y1);
for (int i = 0; i < entities.size(); i++) {
Entity e = entities.get(i);
if (e != this) if (e.interact(this, activeItem, attackDir)) return true;
}
return false;
} |
3424bfc7-27e8-4c1d-a6c6-dc57a0d77ae7 | 1 | private static void printRLE(ArrayList<int[]> runs) {
System.out.println(" Here is the correct encoding:");
for (int[] run : runs) {
System.out.println(run[0] + "x[red=" + run[1] + ",green=" + run[2]
+ ",blue=" + run[3] + "]");
}
} |
5e0feebb-68db-4677-95f1-df1fe8c7396a | 3 | public Integer getPrice(Chest chest,MaterialData data){
if(chest==null || data==null)
return null;
Object price = stores.get(chest).getPrice(data);
if(price instanceof Integer)
return (Integer) price;
else
return 0;
} |
358f50f2-d25c-47b5-99a8-00d6e4399032 | 2 | public void accept(final MethodVisitor mv) {
int[] keys = new int[this.keys.size()];
for (int i = 0; i < keys.length; ++i) {
keys[i] = ((Integer) this.keys.get(i)).intValue();
}
Label[] labels = new Label[this.labels.size()];
for (int i = 0; i < labels.length; ++i) {
... |
6c094d0a-2ddf-4d1a-854a-a37c9e61dd90 | 2 | private void endActionUpdate() {
numberOfActionsAlreadyPassed++;
if (numberOfActionsAlreadyPassed >= numberOfActionsToSwitchStatus) {
numberOfActionsAlreadyPassed = 0;
if (isActive())
deactivate();
else
activate();
}
} |
f0e6eeba-4fe2-40d8-9a3d-afe067ab2048 | 7 | private void createFromParseList(ParseList list) throws CriticalFailure
{
list.insertBlockIDs(blockMap);
Hashtable<String,TreeNodeArea> areas = list.createAreaNodes();
Hashtable<String,Modifier> modifiers = list.createModifiers();
Hashtable<String,ModifierGroup> modifierGroups = list.createModifierGroups();
... |
f9acd4ff-f494-45bf-a234-260635392617 | 8 | private Color parseRGBA(String str) {
int i0 = str.indexOf("[");
if (i0 == -1)
i0 = str.indexOf("(");
int i1 = str.indexOf("]");
if (i1 == -1)
i1 = str.indexOf(")");
str = str.substring(i0 + 1, i1);
String[] s = str.split(REGEX_SEPARATOR + "+");
if (s.length < 3) {
out(ScriptEvent.FAILED, "Cannot... |
88eae2bc-8b4b-430d-ade0-671d874b1163 | 1 | public void fire(ArrayList<Sprite> spriteList)
{
// Only fire if we're loaded.
if (_ammo != null)
{
Vector2d fireImpulse = new Vector2d(_impulseMagnitude, 0);
Vector2d initialTranslation = new Vector2d(_radius / 2, 0);
fireImpulse.setAngle(getAngle());
... |
4efecd91-abaf-4f2a-9ea8-28476416aca0 | 8 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Node otherNode = (Node) obj;
if (edges.size() != otherNode.edges.size())
return false;
/*if (suffixLink == null) {
if (oth... |
ba33f9fe-786b-4d8f-8184-9423b3fee823 | 5 | public static boolean equalsIgnoreCaseInString(String longer, int ai, String shorter, int bi) {
int chkLen = shorter.length() - bi;
if (longer.length() - ai < chkLen) return false;
for (int c = 0; c < chkLen; ai++, bi++, c++) {
char ac = longer.charAt(ai);
char bc = shorter.charAt(bi);
if (ac == bc
|... |
c798c365-2409-4bc3-99e2-325d23b1094b | 6 | @Override
public void tick() {
super.tick();
if (input.escape.clicked) System.exit(0);
if (input.enter.clicked) {
if (selected == 0) System.exit(0);
}
if (input.backspace.clicked) {
if (input.keyboardString.length() > 0) {
input.keyboardString = input.keyboardString.substring(0, input.keyboardStrin... |
69fd23e8-4433-4803-912b-8f2df8d53458 | 0 | public Item SwapWeapon(Item willBeSwappedItem) {
return weaponSlot.swap(willBeSwappedItem);
//return false;// swap failed
} |
7554fffe-4266-4571-bb07-3c1885bb078c | 2 | public OneFlower(GameMode mode)
{
this.mode = mode;
frame = new JFrame();
frame.setTitle("OneFlower - Playing - Score: 0");
frame.setLocationRelativeTo(null);
frame.setSize(390, 410);
frame.setResizable(false);
frame.setLayout(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setV... |
064dcb52-86ec-43d5-84b7-8d12b6bd4c4a | 0 | public void setTotalNumberOfMatches(int totalNumberOfMatches) {this.totalNumberOfMatches = totalNumberOfMatches;} |
d983199b-c1c3-4111-b99b-eaf01f83c083 | 8 | public static void testMethod(int led)
{
int number;
if(led>=0 && led <8)
{
number = led;
}
else
{
number = 7;
}
for (int j = 2; j >=0 ; j--)
{
for (int i = number; i >=0 ; i--)
{
switch(j)
{
case 2:leds[i].setColor(LEDColor.RE... |
1fa329fa-750e-447d-a21e-1c55033537a2 | 8 | public final void attrSplit(int attr, Instances inst) throws Exception {
int i;
int len;
int part;
int low = 0;
int high = inst.numInstances() - 1;
PairedStats full = new PairedStats(0.01);
PairedStats leftSubset = new PairedStats(0.01);
PairedStats rightSubset = new PairedStats(0.0... |
494d50fb-2c81-4137-b468-a4a0f7e356ee | 5 | public static ArrayList<Achievement> updateAchievement(User user) {
ArrayList<Achievement> records = AchievementRecord.getAchievementsByUserID(user.userID, QUIZ_TAKEN_TYPE);
ArrayList<Achievement> newAchievements = new ArrayList<Achievement>();
int totalTakenQuiz = QuizTakenRecord.getQuizHistoryByUserID(user.user... |
832d10b2-0192-42d3-ab49-1fc3305a6699 | 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://down... |
2619dc77-0a2d-44e6-bb9d-75aae323269b | 3 | @Override
protected TerminalSize calculatePreferredSize() {
if(preferredSizeOverride != null)
return preferredSizeOverride;
int maxWidth = 5; //Set it to something...
for(int i = 0; i < items.size(); i++) {
String itemString = createItemString(i);
... |
92979fda-3901-436f-aa01-9cf8b8fd243f | 3 | public synchronized String toString(){
String stringgedField = "";
for (int i = 0; i < this.getYLength(); i++) {
stringgedField = stringgedField + '\n';
for (int j = 0; j < this.getXLength(); j++) {
if (field[j][i] == null) {
stringgedField = s... |
9affbc5b-3769-47e4-8a2b-4b250cb0a5fc | 6 | public void draw(Graphics g)
{
int minx = (int) (worldx / Texture.tilesize);
int maxx = (int) ((worldx + Main.width) / Texture.tilesize) + 1;
int miny = (int) (worldy / Texture.tilesize);
int maxy = (int) ((worldy + Main.height) / Texture.tilesize) + 1;
if(maxx > width) maxx = width;
if(maxy > height) max... |
9964f899-51df-4f95-af2c-38a8c63e25e9 | 6 | public String getHtmlTr() {
try {
JSONObject file = new JSONObject(read());
StringBuffer output = new StringBuffer("<tr><td>");
// Datum
Date d = new Date(file.getLong("datetime"));
output.append(String.format("%tF %tR", d, d));
output.append("</td><td>");
// Informationen
if (file.has("fi... |
1477f609-ee54-4d48-81d3-a02f5484226c | 1 | public boolean accept(File file)
{
if (file.isDirectory())
{
return true;
}
else
{
return false;
}
} |
faea36ea-1bf0-49f4-a6cc-3fc3ebb9273e | 3 | @Test
public void RandomRotatingGrid() {
//Make two identical models but one parallel and one sequential
AbstractModel paraModel=DataSetLoader.getRandomRotatingGrid(100, 800, 40, new ModelParallel());
AbstractModel seqModel=DataSetLoader.getRandomRotatingGrid(100, 800, 40, new Model());
//Step through each mo... |
a111ed03-9a89-4d03-9c0e-eb2a2b8e9127 | 8 | @Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if(Analysis.imageA == null || Analysis.imageB == null) return;
Graphics2D g2d = (Graphics2D)g;
Image A = Analysis.imageA;
Image B = Analysis.imageB;
double ... |
3232f0da-3dae-4e74-985a-842f2e42aa37 | 6 | public synchronized void reap()
{
_log.trace("Running the reaper.");
// DON'T FEAR THE REAPPER!!!!!
long now = System.currentTimeMillis();
List<String> mapRemovalList = new LinkedList<String>();
for(List<DNSRecord> list : _Cache.values()) {
List<DNSRecord> removalList = new Li... |
20f87a89-d6c9-41c6-9888-bdf73b991d37 | 1 | public void visitSwitchStmt(final SwitchStmt stmt) {
if (stmt.index == from) {
stmt.index = (Expr) to;
((Expr) to).setParent(stmt);
} else {
stmt.visitChildren(this);
}
} |
6f36397b-c821-4237-aa35-f769682d703c | 7 | private Value runMethod(CodeBlock i) throws InterpreterException {
if (method_.equals(Length)) {
try {
return new Value(var_.getValue().getArray().size());
} catch (Exception e) {
throw new InterpreterException(e.getMessage(), getLine());
}
} else if (method_.equals(Add)) {
try {
Value v = a... |
4bdd2ac9-ca50-4491-b3bb-c7cce31a35aa | 7 | private void split(Node node){
Node nodeL=new Node(ORDER);
Node nodeR=new Node(ORDER);
MyRecord keyUp=node.getKeys().get(HALF_KEY);
//already full and one more entered to be split
for(int i=0;i<HALF_KEY;i++){
nodeL.getKeys().add(node.getKeys().get(i));
}
for(int i=HALF_KEY+1;i<ORDER;i++){
no... |
b121b688-e367-4d3f-a0aa-ce49eb40ce3d | 7 | private String decodePapPassword(byte[] encryptedPass, byte[] sharedSecret)
throws RadiusException {
if (encryptedPass == null || encryptedPass.length < 16) {
// PAP passwords require at least 16 bytes
logger.warn("invalid Radius packet: User-Password attribute with malformed PAP password, length = " +
e... |
61ebe91f-aefd-4231-83cb-3bb1ee39370f | 1 | public static void TakesScreenshot(WebDriver driver, String FailedAt){
try{
// driver is your WebDriver
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
// screenshot is the file we have acquired
// fileName is the name of the image file
FileUtils.copyFil... |
7cabdeec-3973-45b4-9692-5f84a33545f9 | 4 | public boolean controlErroresHorarios(Object datos)
{
boolean correcto=false;
ArrayList<Object> entrada = (ArrayList<Object>)datos;
String empleado=(String)entrada.get(0);
String turno=(String)entrada.get(1);
if(!turno.isEmpty() && !empleado.isEmpty())
{
i... |
d85a36e4-2191-4194-a0ad-4fd1e2f25836 | 7 | public void start() throws JSchException{
Session _session=getSession();
try{
Request request;
if(xforwading){
request=new RequestX11();
request.request(_session, this);
}
if(pty){
request=new RequestPtyReq();
request.request(_session, this);
}
request=new R... |
7730ab62-7235-47fc-9869-7bd9573206a6 | 2 | private static void registrarTienda()
{
boolean salir;
String nombre, cif;
float deuda;
Tienda tienda;
do
{
try
{
System.out.print( "Introduce el nombre de la tienda: ");
nombre = scanner.nextLine();
System.out.print( "Introduce el cif de la tienda: ");
cif = scanner.nextLine... |
bfe3380f-755b-4027-ab4a-85dbd73a1ac2 | 4 | public void addNote(String channel, String sender, String message) {
String[] split = message.split(" ");
if(message.equalsIgnoreCase(Config.getCommandPrefix() + "note")) {
this.bot.sendMessage(channel, "No receiver specified, please try again.");
return;
}
... |
d11bcadd-4535-414b-b0ee-2dde120bf43a | 7 | public static void main ( String[] args ) {
String xmldata = "<loadcell> <sensor id='loadcellid1'/> <weight>156</weight> </loadcell>";
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
StringReader sr = new StringReader(xmldata);
XMLEventReader eventReader = null;
try {
even... |
91d14dc1-e20a-43e6-8439-c314269a719c | 8 | private void writeFolder(Folder folder) throws IOException {
writeNumber(folder.getCoders().size());
int i;
for (i = 0; i < folder.getCoders().size(); i++) {
CoderInfo coder = folder.getCoders().get(i);
{
int propsSize = coder.getProps().getCapacity();
... |
451c01b3-6ede-4479-898b-608d9f5c3c55 | 3 | public String say(String str){
String result = "";
int count =1;
for(int i=0;i< str.length();i++){
if(i==str.length() -1){//因为最后一个没有被计入,需要单独处理
result += count + str.substring(i,i+1);
count = 1;
}
else if(str.charAt(i) ==str.cha... |
9992b634-5568-402a-a9c5-9ade5d816f96 | 7 | public String processInput(String input) {
stringParts = input.split(" ");
try {
cmdPart = stringParts[0];
} catch (NullPointerException e) {
System.out.println("Error: found no Command");
}
if (input.equals("SYN")) {
return ack;
}
if (cmdPart.equals("!login")) {
return logginUser();
... |
0eed97d1-9509-45f2-aff7-7d2860263dc9 | 1 | private static String getOS() {
if (os == null) {
os = System.getProperty("os.name");
}
return os;
} |
965da10c-e7ad-4305-aa30-1f405947d662 | 0 | public VenueRemovalFinalized(Venue venue)
{
this.venue = venue;
} |
ab486ccb-36c9-4ba0-a667-6d34ea7c5347 | 2 | public static void main(String[] args) {
System.out.println("This is a binary to decimal converter.");
System.out.println("Please choose your option:");
System.out.println("1. Convert binary to decimal.");
System.out.println("2. Convert decimal to binary.");
System.out.p... |
37f2583a-5fa7-4005-bce6-f78baf5512ed | 6 | private void knightTopTopRightPossibleMove(Piece piece, Position position)
{
int x1 = position.getPositionX();
int y1 = position.getPositionY();
if((x1 >= 0 && y1 >= 0) && (x1 < 7 && y1 <= 5))
{
if(board.getChessBoardSquare(x1+1, y1+2).getPiece().getPieceType() != board.getBlankPiece().getPieceType())
... |
24d2fbfd-9c24-4e82-a687-66ac05631114 | 6 | public double getSimRevenue(int s2,int s3,int s4){
int phantom_capacity = max_capacity;
int phantom_rev = 0;
int phantom_level = 1;
for(int t=1;t<=no_weeks;t++){
if(t>=s4){
phantom_level = 4;
}
else if(t<s4 && t >= s3){
phantom_level = 3;
}
else if(t<s3 && t >= s2){
phantom_leve... |
1ee6ee0c-7b46-4055-8b8d-7b04d637adab | 5 | public boolean isCardPlayable(Card card) {
return card != null &&
(playPile.isEmpty() ||
card.value == Card.EIGHT ||
card.value == playPile.peek().value ||
((playPile.getComponent().hasCardFacade()) ? card.suite == playPile.getComponen... |
b4e83268-d106-4e6a-96c2-2eb687a978f2 | 3 | public char skipTo(char to) throws JSONException {
char c;
try {
long startIndex = this.index;
long startCharacter = this.character;
long startLine = this.line;
this.reader.mark(1000000);
do {
c = this.next();
if... |
964606d1-3e97-40e5-9deb-794edad7363e | 1 | @Test
public void testTrafficLights() {
for (TrafficLight trafficLight : TrafficLight.values()) {
System.out.println(trafficLight);
System.out.println(trafficLight.getDuration());
}
} |
7a3efbf7-fdc4-4c59-bab0-ed0f835f9db1 | 0 | public JLabel getjLabelNom() {
return jLabelNom;
} |
f7e294f1-3dd9-4189-95f9-2bf171a6b236 | 5 | public void paintComponent(Graphics g)
{
if(drag==true)
{
if(startDragX-xMouse < 0 & startDragY- yMouse < 0)
{
dragRect = new Rectangle(startDragX,startDragY,xMouse-startDragX,yMouse-startDragY);
}
else if(startDragX-xMouse < 0 & yMouse - startDragY < 0)
{
dragRect = new Rectangle(startDra... |
a3e72edb-012f-4568-97b8-6a2c8e29498c | 3 | public boolean alreadyInFile(String name) {
File file = new File("Users.txt");
Scanner scanner;
try {
scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String lineFromFile = scanner.nextLine();
if(lineFromFile.contains(name)) {
JOptionPane.showMessageDialog(null, "Username has a... |
07804107-d198-416a-ad8c-fbfaf8d49ff6 | 8 | public StringBuffer startTable(StringBuffer org, MutableAttributeSet attrSet) {
originalBuffer = org;
ret = new StringBuffer();
tblno = tblcnt++;
tc = ""+(char)('a'+(tblno/(26*26)))+
(char)((tblno/26)+'a')+
(char)((tblno%26)+'a');
String val = (Strin... |
83d476d7-a4b7-4447-a9a1-ee42d5e6e000 | 8 | private void loadGame(){
try{
contrlSaveLoad.load();
}catch(Exception e){
e.printStackTrace();
}
//load main
currentCity = contrlSaveLoad.getCity();
contrlSaveLoad.getSec();
setHandCash(contrlSaveLoad.getCash());
setBankCash(contrlSaveLoad.getBankCash());
setCurrentQuest(contrlSave... |
f056e5bf-0772-4b9c-9c75-64e093b72c59 | 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://down... |
6d300217-8197-4707-9431-c0c53b532396 | 4 | public boolean jumpMayBeChanged() {
return (thenBlock.jump != null || thenBlock.jumpMayBeChanged())
&& elseBlock != null
&& (elseBlock.jump != null || elseBlock.jumpMayBeChanged());
} |
eb5f669e-ca57-4656-a108-bc56125f6e1f | 1 | private void createSocketAndSend(String msg, int flag) throws IOException{
DatagramSocket clientSocket = new DatagramSocket();
String[] ipNumbers = hostIP.split("\\.");
byte[] ip = {(byte) Integer.parseInt(ipNumbers[0]),
(byte) Integer.parseInt(ipNumbers[1]),
... |
2f59315a-8ebf-49a1-b7de-659e05c3d515 | 9 | @Override
public void executeMsg(final Environmental myHost, final CMMsg msg)
{
boolean unSpring=false;
if((!sprung)
&&(affected instanceof Room)
&&(msg.amITarget(affected))
&&((msg.targetMinor()==CMMsg.TYP_ENTER)
&&(!msg.source().isMine(affected)))
&&(msg.tool() instanceof Exit))
{
final Room room... |
9a2be1f7-93aa-4502-9234-2ed19f84ea45 | 1 | public boolean needShuffle() // ->brought from DeckArrayManager
{
if (count == 52)
return true;
else
return false;
} |
ad554e4f-5c42-4942-8cf9-7dab3a1fecb5 | 2 | public Bag getDiscsWithStability(Stability stability) {
LOGGER.log(Level.INFO, "Getting discs with stability " + stability);
Bag discBag = new Bag();
for (int i = 0; i < discs.size(); i++) {
if (discs.get(i).getStability() == stability) {
discBag.addDisc(discs.get(... |
ae623bb4-4110-49c5-ade3-d40ddf27f2bd | 7 | private void paivitaJaLinkitaSolu(int x, int y) {
Solu solu = solut[x][y];
for (int i=x-1;i<x+2;i++){
for (int k=y-1;k<y+2;k++){
if (onKartalla(i, k) && solut[i][k]==solu){
k++;
}
if (onKartalla(i, k)){
... |
3e25a5ce-34d5-4585-804a-e5fa8cca438e | 0 | public void setSeatType(long value) {
this._seatType = value;
} |
eacbcc2b-0faa-4b98-af99-8d50c21b8ee0 | 9 | private boolean send(String mediaId, List<String> recipients, boolean story, int time) {
try {
// Prepare parameters
Long timestamp = getTimestamp();
String requestToken = TokenLib.requestToken(authToken, timestamp);
int snapTime = Math.min(10, time);
... |
95b7808b-50ba-46e3-a3d2-55736751f7c5 | 4 | public PwdItem GetItem(int id) {
PwdItem item = new PwdItem();
if (this.connection == null) {
return null;
}
try {
Statement stmt = null;
stmt = this.connection.createStatement();
int count = 0;
//find the max id
... |
034d92b0-5186-44dd-9787-81024148542f | 6 | @Override
public LinkedList<Item> getItems(String[] params) {
LinkedList<Item> foundItems = new LinkedList<Item>();
for(Item item : items){
boolean addItem = true;
//Test against Name
if(!params[0].isEmpty() && !params[0].equals(item.getName())){
addItem = false;
}
//Test against Category
... |
3f917cbf-c343-49de-b6d3-4390b6f6fa6c | 5 | public void writeSrcCoor(String projN, String cycle){
ArrayList<String> srcCoor=rfa.readInputStream(GenerateInitScripts.class.getResourceAsStream("config/common/coordinator.xml"),"UTF-8");
StringBuffer content=new StringBuffer();
String cycleTag="${coord:days(1)}";
if(cycle.equalsIgnoreC... |
fff00493-8889-4984-93d2-623a54f2958e | 4 | public static int triangleBmax(int x[][]) {
int max = x[0][0];
for (int i = 0; i < x.length; i++) {
System.out.print("\n");
for (int j = 0; j < x[i].length; j++) {
if (i >= j) {
System.out.print(x[i][j] + " ");
if (max < x[i][j]) {
max = x[i][j];
}
}
}
}
System.out.println(... |
8ce181af-6f2d-4d14-ba21-d5c871a88965 | 3 | private double gcf(double x, double a) {
int i;
double gold = 0, g, a0 = 1, a1 = x, b0 = 0, b1 = 1, fac = 1, anf, ana;
for (i = 1; i <= ITER_MAX; i++) {
ana = i - a;
a0 = (a1 + a0 * ana) * fac;
b0 = (b1 + b0 * ana) * fac;
anf = i * fac;
a1 = x * a0 + anf * a1;
b1 = x * b0 + anf * b1;
if (a1 ... |
513999ec-b297-4e31-a001-10be20ad3a1e | 8 | public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
LinkedList<ListNode> lists3 = new LinkedList<ListNode>();
int flag = 0;
int sum = 0;
ListNode pre = new ListNode(0);
// first step
sum = l1.val + l2.val;
if (sum > 9) {
flag = 1;
}
else{
flag = 0;
... |
2da80abd-94ec-4cf3-96fb-f722ee68ee77 | 2 | public static void deleteCompte(Compte compte) {
Statement stat;
try {
stat = ConnexionDB.getConnection().createStatement();
stat.executeUpdate("delete from compte where id_compte="+ compte.getId_compte());
} catch (SQLException e) {
while (e != null) {
... |
29cd809e-652b-4ae7-920f-ebdec3e6b98b | 8 | @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length <= 0) {
return false;
}
if (args[0].equalsIgnoreCase("debug-mode")) {
if (args.length == 2) {
boolean newDebugMode = Boole... |
87948a3f-4a1b-411c-aae3-a002907f491a | 1 | public void spawnEnemy()
{
int x = random.nextInt(width);
int y = random.nextInt(height);
if(tiles[x][y].isObstacle())
{
spawnEnemy();
return;
}
Enemy e = new Enemy(x * Texture.tilesize, y * Texture.tilesize, 0, 0);
e.setPath(graph.astar(graph.getNodeID(x, y), graph.getNodeID(getPlayerTilePosX(), g... |
a615bc44-abb7-4758-8efe-4a2d8357f775 | 5 | private void setDialogActionListeners() {
//handles when the initial dialog is closed; kills the client
dialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
client.kill();
}
});
//handles what ... |
960fc4d0-f5fb-43a8-a9fc-387deb3e5810 | 1 | public void playSound(String path)
{
try
{
in = new FileInputStream(path);
as = new AudioStream(in);
ap.player.start(as);
}
catch(Exception e)
{
System.out.println("Got an IOException: " + e.getMessage());
e.printStackTrace();
}
} |
7794d85c-1a69-4902-b2e8-8eef9389e2aa | 2 | public boolean isExistingProfil(String nom) {
Iterator iterator = this.getAllProfils().keySet().iterator();
while (iterator.hasNext()) {
if (((Profil) this.getAllProfils().get(iterator.next())).getNom().equals(nom)) {
return true;
}
}
return ... |
402dc5f5-4eb5-4a3f-b2d0-b08ccb1ccb4f | 6 | @Override
public void onEnter() {
Bukkit.getWorlds().get(0).setDifficulty(Difficulty.PEACEFUL);
for (Player player : Bukkit.getOnlinePlayers()) {
player.teleport(Util.parseLocation(getGame().getPlugin().getConfig().getString("game.respawn"), true));
}
for (Entity entit... |
882a6431-2664-4fe9-8b59-8676adf56ef0 | 9 | public List<FoodDataBean> getArticleList(int start, int end) throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
List<FoodDataBean> articleList = null;
String sql = "";
try{
conn = getConnection();
/*추천지수 불러오는sql*/
sql = "update food set recommand_count =... |
334b0f29-94a5-4963-934f-3103c10c8dc2 | 5 | public String toString(StringBuilder all, StringBuilder word) {
if (this.value > 0) {
all.append(word.toString()).append(" ").append(this.value).append("\n");
}
if (this.nodes != null) {
for (int i = 0; i < this.nodes.length; i++) {
if (this.nodes[i] != nu... |
940af8d1-556a-4d92-8582-1c08c06a4036 | 4 | public int[] randomTags(int L, int n) {
int[] slots = new int[L];
for(int i = 0; i < n; i ++) slots[(int)(Math.random()*L)]++;
int[] status = new int[3];
for(int i : slots) {
if(i == 0) status[0]++;
else if( i == 1) status[1]++;
else status[2]++;
}
return status;
} |
4e8e2f70-21a2-430e-bf56-a2adb2e63aa8 | 3 | private void updateShip(Info info) {
Node nodeOne;
Node nodeTwo;
Set<Node> nodes;
// visit every edge in the actual ship
for (Edge e : info.adjacentEdges) {
nodeOne = info.location;
nodeTwo ... |
097185c1-6f4a-478d-90dc-0682ade7c2e7 | 6 | @Override
public void run() {
try {
serverSocket = new ServerSocket(SERVER_DATA_SOCKET);
while (true) {
// wait for a client request and when received assign it to the
// client socket
// when u wanna send data to that client u'll use ... |
c7981df6-304b-4527-b381-b12862786d47 | 9 | public Collection<T> readAll() {
SQLStrings.INSTANCE.getReadAllElementsString();
Collection<T> result = null;
Connection conn = hsqlh.createConnection();
try {
/*
PreparedStatement prep_stmt = conn.prepareStatement(SQLStrings.INSTANCE.getReadAllElementsString());
prep_stmt.clearPar... |
cbba9d94-ddb5-48c8-a9c3-29f390bdc13c | 5 | public boolean addWord(String word){
CharNode temporary_node;
CharNode temporary_child;
int i=1;
if(word.length() <= 0)
return false;
if(this.head.getChar() != word.charAt(0))
return false;
temporary_node = this.head;
for(i=1; i < word.length(); ++i){
if((temporary_child = temporary_... |
08eabafb-eb90-4dc9-b030-183b54887c5c | 3 | public void fulfillOrder()
{
try
{
PreparedStatement stmt = connection.prepareStatement("select sum(i.price * c.amount * d.percent) as total " +
" from martitem i " +
"join cartitem c on i.stock_number = c.stock_number " +
"join discount d on d.status = ? " +
"where trim(c.cid) = ? ");
s... |
07d70e4e-1e58-45c4-80ea-6c4101df805c | 9 | public synchronized void handle(String userID, int ID, String input) {
StringTokenizer in = new StringTokenizer(input, " ");
String command = in.nextToken();
System.out.println(command);
if (command.equals(".bye")) {
clients[findClient(ID)].send(".bye");
remove(ID);
} else if (command.equals(".create"))... |
a941c623-557c-4476-b0d8-9ce4add028fe | 1 | public ArrayList<String> theatricalsToList(){
ArrayList<String> temp = new ArrayList<>();
for (Theatrical theatrical : theatricals) {
temp.add(theatrical.getName());
}
return temp;
} |
8511c9f7-9c5c-412b-8283-8f1d6a4b44f8 | 5 | public int readInput() {
System.out.println("Vad vill du göra? ");
System.out
.println("1) Visa alla journaler \n 2) Visa en journal \n 3) ändra journal(er) \n 4) Skapa ny journal \n 5) Ta bort ");
String input = scan.nextLine();
String addText = "";
if (input.equals( "1")) {
System.out.println(s... |
174e5d05-8997-4a45-acd6-230db0bcacb5 | 9 | final boolean isValidHost() {
anInt40++;
String string = getDocumentBase().getHost().toLowerCase();
if (string.equals("jagex.com") || string.endsWith(".jagex.com"))
return true;
if (string.equals("runescape.com")
|| string.endsWith(".runescape.com"))
return true;
if (string.endsWith("127.0.0.1"))
... |
6fc1ddb4-3cb0-4eda-937b-81534804560f | 4 | public void editDataLevel(String name, double totalPoints) {
path = name;
File f = new File(plugin.getDataFolder() + File.separator + "Players" + File.separator + name + ".data");
try {
if (!f.exists()) {
saveDataFirst(name);
}
BufferedReader br = new BufferedReader(new FileReader(f));
FileWrite... |
24e68cf3-8566-4e0d-9d15-490890137a32 | 6 | private List expandContext(List symbols) {
List ne = new ArrayList();
for (int i = 0; i < symbols.size(); i++) {
String s = (String) symbols.get(i);
ArrayList replacementsList = new ArrayList();
for (int j = 0; j < contexts.length; j++) {
List[] l = contexts[j].matches(symbols, i);
for (int k = 0; ... |
4000e1a5-0974-475f-a1b7-e7e04c8e6721 | 8 | public void imc_process_call_outs()
{
if (call_outs.size() < 1)
{
return;
}
for (int i = 0; i < call_outs.size(); i++)
{
final Vector call_out = (Vector) call_outs.get(i);
final String fun = (String) call_out.elementAt(0);
final long hbeat = ( (Long) call_out.elementAt(1)).longValue();
final ... |
98c567c9-849e-4164-b1ba-bc942fd276e0 | 8 | public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) {
String add = ", img: " + img + ", flags: " + flags + ", x/y: " + x + "," + y + ", width: " + width + ", height: " + height;
if ((flags & ABORT) != 0)
CoffeeSaint.log.add("Image aborted" + add);
if ((flags & ALLBITS) != 0)
... |
19f13e9b-c218-4b53-82d8-e6929491c235 | 9 | void writeRequest(OutputStream out) throws IOException {
DataOutputStream data = new DataOutputStream(new BufferedOutputStream(out));
if ((doOutput) && (output == null)) {
throw new IOException(Messages.getString("HttpsURLConnection.noPOSTData")); //$NON-NLS-1$
}
if (ifModifi... |
a6d5a9e1-dd12-4eb7-aa63-5d47b766edd6 | 7 | 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://down... |
23f8ccc3-60b9-470e-ab7a-7f4471096f9c | 3 | public void changeCase(boolean upper)
{
for (int x = 0; x < grid.length; x++)
{
for (int y = 0; y < grid[x].length; y++)
{
String c = String.valueOf(grid[x][y]);
c = upper ? c.toUpperCase() : c.toLowerCase();
grid[x][y] = c.charAt(0);
}
}
} |
fef7f3b9-d4ee-413b-8ea0-9dcbe9cdc604 | 2 | public static void decodeFileToFile( String infile, String outfile )
throws java.io.IOException {
byte[] decoded = Base64.decodeFromFile( infile );
java.io.OutputStream out = null;
try{
out = new java.io.BufferedOutputStream(
new java.io.FileOutputStrea... |
5bb0578c-560c-40a2-bee0-f39cea72b391 | 3 | public Object next() {
Object o = null;
// Block if the Queue is empty.
synchronized(_queue) {
if (_queue.size() == 0) {
try {
_queue.wait();
}
catch (InterruptedException e) {
r... |
89ca48ee-4f01-4b6d-bc78-730faae63a55 | 5 | public void hit(GroupOfUnits target)
{
int no = 0;
try {
no = target.getNumber();
} catch (NullPointerException e) {
return;
}
if (humanPlaying()) {
if (currentUnit.type.shooting) {
gui.Sound.play("sound/shot.wav");
} else {
gui.Sound.play("sound/attk.wav");
}
}
QApplication... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.