method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
83b7eb54-652f-4e87-8cfe-00d4ec2fb24e | 9 | @Override
public boolean equals( Object other ) {
if ( other == this ) {
return true;
}
if ( !( other instanceof TFloatList ) ) return false;
if ( other instanceof TFloatArrayList ) {
TFloatArrayList that = ( TFloatArrayList )other;
if ( that.size... |
ff20a49b-9a2b-4fdf-a70d-627a4619f3ea | 7 | private String withdrawSavings(Scanner in) throws FileNotFoundException
{
System.out.println("Current balance: " +
supportedBank.getSavingsBalance(currentCustomer));
boolean successWithdraw = false;
while(!successWithdraw)
{
System.out.println(
"Please enter an... |
d124d895-22c9-403f-9e56-9fd7bcea4020 | 7 | public static void main(String[] args) {
currentPathExtensions = Installation.class.getProtectionDomain()
.getCodeSource().getLocation().getPath()
.replaceAll(Installation.filenameJar, "");
Control.writeFile(currentPathExtensions + "BEval.sh",
Installation.bEvalSh.replaceFirst("!currentPathExtensions... |
93c6ac04-9d59-4bbd-9855-45d98ae31e0f | 6 | protected void movePlayHead(int delta) {
if (flip && Math.abs(delta) == 1) return;
if (Math.abs(delta) > 1) delta /= 2;
SimStream stream = model.getStream();
int index = model.getPlayHead() + delta;
if (!model.isLoaded()) return;
while (index > stream.getMaxIndex()) {
model.... |
a4cb6828-aa71-479a-929f-f9d980357869 | 3 | public void Save_Waypoints()
{
try
{
FileWriter fw = new FileWriter(System.getProperty("user.dir") + "/" + "level_waypoints.cfg", false);
BufferedWriter output = new BufferedWriter(fw);
for (Waypoint curr : waypoints)
{
output.write(String.format("\n"));
output.write(String.format("%d %d\n", (... |
ad5a8a0a-5030-4270-ba86-a126daa9d334 | 7 | private int buildStraight(int xo, int maxLength, boolean safe)
{
int length = random.nextInt(10) + 2;
if (safe) length = 10 + random.nextInt(5);
if (length > maxLength) length = maxLength;
int floor = height - 1 - random.nextInt(4);
for (int x = xo; x < xo + length; x++)
... |
b96e1925-d5ff-49a3-9147-9f4345a475ae | 8 | public void add(String str)
{
Node current = this.HEAD;
Node[] update = new Node[MAX_LEVEL + 1];
for (int i = this.level; i >= 0; i--)
{
while (current.pointer[i] != null
&& current.pointer[i].val.compareTo(str) < 0)
{
current = current.pointer[i];
... |
7446b29b-165b-4e37-a6a5-fe9ea9adf815 | 6 | public String encode(String plain)
{
String v_key_u=v_key.toUpperCase();
// String h_key_u=h_key.toUpperCase();
char[][] ct_table=new char[v_key_u.length()][26];
for(int i=0;i<v_key_u.length();i++)
{
// int mv_pos=0;
char first_c=v_key_u.charAt(i);
char[] ct_line=build_keyed_alphabet(h_key,26,0);
... |
cae1f090-b775-432b-b1fa-d7faff62fd61 | 3 | public void update(PeerState state, long uploaded, long downloaded,
long left) {
if (PeerState.STARTED.equals(state) && left == 0) {
state = PeerState.COMPLETED;
}
if (!state.equals(this.state)) {
logger.info("Peer " + this + " " + state.name().toLowerCase() +
" download of " + this.torrent + ".");... |
c2e7b97c-308e-4cc5-8eb0-d3c891ab8327 | 8 | public static void InsertInToTable(String table,String[] values){
try {
con = DriverManager.getConnection(url, user, password);
st = con.createStatement();
String insertSQL = "INSERT INTO "+table+" VALUES (";
for (int i = 0; i < value... |
13c84e9b-ca4f-4faa-b680-10f1cfc9c6ac | 0 | @Override
public String getDef() {return def.toString();} |
5a9787da-b3d9-4c0f-b95d-6dc244af443f | 6 | static boolean tagcompare(byte[] s1, byte[] s2, int n) {
int c = 0;
byte u1, u2;
while (c < n) {
u1 = s1[c];
u2 = s2[c];
if ('Z' >= u1 && u1 >= 'A') {
u1 = (byte) (u1 - 'A' + 'a');
}
if ('Z' >= u2 && u2 >= 'A') {
... |
2c77c24f-33a9-47c9-9a7f-0d10a57c05e9 | 7 | public static void main(String[] args){
try{
Chap12Q20 cq = new Chap12Q20();
cq.atBat();
}catch(PopFoul e){
System.out.println(e);
}catch(RainedOut e){
System.out.println(e);
}catch(BaseballException e){
System.out.println(e);
}
try{
Inning i = new Chap12Q20();
i.atBat();
}catch... |
a890e635-6a1d-444e-b313-afc5de50b413 | 2 | public static String introduceXMLEntities(String inputString) {
StringBuffer stringBuffer = new StringBuffer();
int length = inputString.length();
char c;
for (int i = 0; i < length; i++) {
c = inputString.charAt(i);
if (ENTITY_REFERENCES.containsKey(new Character(c))) {
stringBuffer... |
5115f423-5c76-4285-91a5-64888992665b | 6 | private void loadIdCounts()
{
try
{
this.idCounts.clear();
if (this.saveHandler == null)
{
return;
}
File var1 = this.saveHandler.getMapFileFromName("idcounts");
if (var1 != null && var1.exists())
... |
546c4376-67a3-4352-8859-aa63cbf61a24 | 7 | public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player player = (Player) sender;
if (commandLabel.equalsIgnoreCase("Assassin") && sender instanceof Player){
if (player.hasPermission("EasyPvpKits.Assassin")){
if (!plugin.kits.contains(player.getName())){
... |
b4477e0e-f6ff-4f8f-bb95-3b783c341044 | 2 | @FXML
private void handleBtnRegisterAction(ActionEvent event) {
if (!validate()) {
return;
}
String itemCode = txtBarCode.getText();
Item item = select(itemCode);
if (item == null) {
String insert = "INSERT INTO Item (ItemCode, Name, Price, SupplierC... |
e7f21b01-06b5-4b75-86dc-8f720808e062 | 3 | @Override
public void run() {
try {
ss = new ServerSocket(port);
System.out.println("Listening on " + ss);
while (true) {
Socket s = ss.accept();
if (!bannedAddresses.contains(s.getInetAddress())) {
System.out.println("C... |
a1de9c9b-de52-4d7c-b9a8-660a0d2831f9 | 3 | public ArrayList<Tree> findLoopControlStatements(){
ArrayList<Tree> statements = new ArrayList<Tree>();
if(body instanceof LoopControlStatement){
statements.add(body);
return statements;
}
if(body instanceof WhileStatement)
return statements;
if(body instanceof Statements)
statements.addA... |
cb811ecd-f690-4c88-9bc3-f3f13f042c13 | 3 | @Override
public void run() throws ClienteException {
try {
while (seguir) {
Object object = Conexion.getIn().readObject();
AudioChatService.recibirObjeto(object);
}
} catch (IOException e) {
throw new ClienteException("Error al crear la conexion: "
+ e.getMessage(), e);
} catch (ClassNotFo... |
48b5ffd5-c4fe-40db-ac9a-96145d21c5a4 | 3 | @JavaScriptMethod
public boolean toggleDemoMode() {
CiLightGlobalConfiguration config = CiLightGlobalConfiguration.get();
List<Endpoint> endpoints = config.getEndpoints();
for (Endpoint endpoint : endpoints) {
try {
if (demoModeEnabled) {
sendD... |
ae1b3588-2f93-4db6-8290-ff7aeb71b509 | 0 | public void fireKeyEvent(KeyEvent event) {
processKeyEvent(event);
} |
19662c33-d68b-4e52-bddb-2d457f5eb1b9 | 8 | public static void makeKeys ()
{ V=new Vector();
Hmenu=new Hashtable(); Hcharkey=new Hashtable();
// collect all predefined keys
Enumeration e=Global.names();
if (e==null) return;
while (e.hasMoreElements())
{ String key=(String)e.nextElement();
if (key.startsWith("key."))
{ String menu=key.substring... |
44e4050e-dec9-4ec6-b179-40184fb33fbd | 5 | public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
//build a new list
ListNode temp = new ListNode(0);
ListNode move = temp;
//record the sum of the value
int number = 0;
while (l1 != null || l2 != null) {
//check if there is 1 the add up
... |
65ab1354-ff6a-4863-b301-829353d65d57 | 8 | public static File getRelativeFile(File target, File base) throws IOException
{
String[] baseComponents = base.getCanonicalPath().split(Pattern.quote(File.separator));
String[] targetComponents = target.getCanonicalPath().split(Pattern.quote(File.separator));
// skip common components
int index = 0;
... |
dad0c088-4641-49b0-aead-5e98c618f421 | 2 | @Override
public boolean equals (Object obj) {
if (!(obj instanceof TorrentFileInfo)) {
return false;
}
TorrentFileInfo tfi = (TorrentFileInfo) obj;
return tfi.length == length && path.equals(tfi.path);
} |
a44c1c5a-e5be-4210-a0de-cee1a3251f89 | 8 | private int obterUltimoIDdoBD() throws Exception {
String sql = "SELECT max(id) FROM veiculo";
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
con = obtemConexao();
stmt = con.prepareStatement(sql);
rs = stmt.executeQuery();
if(rs != null && rs.next()) {
... |
bf6187d2-89ef-435c-a715-fb3ab546e23d | 2 | public void visitOuterClass(final String owner, final String name,
final String desc) {
enclosingMethodOwner = newClass(owner);
if (name != null && desc != null) {
enclosingMethod = newNameType(name, desc);
}
} |
a9bcce3a-ce7c-41f8-bca6-33965d2cdbdc | 3 | @Command(command = "promote",
aliases = {"pr"},
arguments = {"target player[s]"},
description = "promotes the target player[s]",
permissions = {"promote"},
consoleOnly = true)
public static boolean promoteFromConsole(CommandSender sender, String targetPlayer) throws EssentialsCommandException {
// mak... |
0626983c-48c1-466f-97f7-28b5cc6c5d53 | 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... |
6e48892e-0e69-42a4-97e8-eb3608030fc1 | 1 | @Override
public void execute(ArrayList signature) {
try {
String className = (String) signature.get(1);
String protocolName = (String) signature.get(2);
Outliner.fileProtocolManager.createFileProtocol(protocolName, className);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("ERROR:... |
420732a1-6661-4691-9886-83192aa867a2 | 0 | @Override
public String getDbDriverName() {
return dbdrivername;
} |
a79d6f1d-054e-4040-9eef-fa64201a4ebb | 4 | /*package*/ void packet(Packet packet) {
logger.fine(String.format("writing packet %s", packet));
final Manager self = this;
if (!self.encoding) {
self.encoding = true;
this.encoder.encode(packet, new Parser.Encoder.Callback() {
@Override
... |
985f175e-21e4-47fd-a459-679b94c46aef | 9 | @Override
public PowerHost findHostForVm(Vm vm) {
ArrayList<PowerHost> SuitablesHosts = new ArrayList<>();
PowerHost moreAvailHost = null;
for (PowerHost host : this.<PowerHost> getHostList()) {
if (host.isSuitableForVm(vm)) {
SuitablesHosts.add(host);
}
... |
e46636a1-6d45-4a5b-93f9-e4b50ae493c9 | 9 | static boolean equalIdentity(Matrix3f mat) {
if (Math.abs(mat.m00 - 1) > 1e-4) {
return false;
}
if (Math.abs(mat.m11 - 1) > 1e-4) {
return false;
}
if (Math.abs(mat.m22 - 1) > 1e-4) {
return false;
}
if (Math.abs(mat.m01) > 1e... |
710f074e-8853-4c46-a9ce-c88a89637865 | 2 | private static int value(int[][] ways, int i, int j){
if (i<0 || j<0) return 0;
else return ways[i][j];
} |
d04d900a-5ec3-41cd-bf53-66d75d375dc5 | 7 | public static String blessings(Deity E, HTTPRequest httpReq, java.util.Map<String,String> parms)
{
while(E.numBlessings()>0)
{
final Ability A=E.fetchBlessing(0);
if(A!=null)
E.delBlessing(A);
}
if(httpReq.isUrlParameter("BLESS1"))
{
int num=1;
String aff=httpReq.getUrlParameter("BLESS"+num);... |
7440c1fe-bb5a-45bc-871a-97ab713d9191 | 1 | public hanoiTowers(int count) {
stack1 = new Stack<Integer>();
stack2 = new Stack<Integer>();
stack3 = new Stack<Integer>();
for (int i = count; i > 0; i--) {
stack1.push(new Integer(i));
}
} |
85d956d1-8ceb-45a3-aa65-354b577397c0 | 3 | @Override
public boolean isTypeOf(Property p) {
if(p==null)
return true;
if(equals(p))
return true;
if(this.superProperty!=null) {
return this.superProperty.isTypeOf(p);
}
return false;
} |
573e80d7-687d-4d12-b3b4-bc0355d8351c | 7 | synchronized Connection getConnection() throws JMSException, TemplateClosedException {
if (closed.get()) {
throw new JMSException("JMSTemplate Closed");
}
if (connection == null) {
connection = getConnectionFactory().createConnection();
connection.setException... |
e1c6eff0-8188-4ece-ade9-1fdf5ac8da53 | 8 | public KeyStroke createKeyStroke() {
KeyStroke result = null;
int modifiers = 0;
if (isAcceleratorCtrlMask()) {
modifiers = modifiers | InputEvent.CTRL_MASK;
}
if (isAcceleratorShiftMask()) {
modifiers = modifiers | InputEvent.SHIFT_MASK;
}
if (isAcceleratorAltMask()) {
modifiers = modifiers | In... |
efcbac29-79e8-4a0b-a0e5-d972dc868b73 | 9 | public static void testSystem(String qPath, String docsPath) {
window.clearWindow();
// only create docSet once
if ( docSet == null || !(docsPath.equals(documentsPath)) ) {
long docStart = System.currentTimeMillis();
documentsPath = docsPath;
docSet =... |
e31be787-b5c2-44d3-92e4-c1bacbe62129 | 0 | public Trame(int id, int dlc, long date, int[] data) {
this.id = id;
this.dlc = dlc;
this.date = date;
this.data = data;
} |
e593a898-2bba-4371-86c8-07cd63a8251e | 6 | private Node encontrarHojaDondeEstaQ(Node node, double[] q) {
comparaciones++;
node.setVisitado(true);
if (node.getLeft() == null || node.getRight() == null) {
double distNueva = Math.sqrt((Math.pow((q[0] - node.getValue()[0]),
2) + Math.pow((q[1] - node.getValue()[1]), 2)));
distActual = distNueva;
... |
5bb9cff5-1a77-438c-85dd-f5fcdb6c35ef | 6 | public void commit(Instruction instruction) {
String d = ROB.getEntry(ROB.getHead()).getDest();
String value = ROB.getValue(ROB.getHead());
String type = instruction.getOpcode();
if (type.equals("BEQ")) {
} else if (type.equals("SW")) {
String regVal = getRegister(d).getValue();
memory.iMemory.put(regV... |
4bb8885d-9fed-4c81-8526-4c32d218b2f0 | 0 | private int getShortBigEndian(byte[] a, int offs) {
return
(a[offs] & 0xff) << 8 |
(a[offs + 1] & 0xff);
} |
634be38d-5e7e-40cf-8b7e-552e25bc6294 | 0 | @Override
public boolean supportsDocumentAttributes() {return false;} |
e6f64088-74c6-4530-96f5-ee7e57d7505d | 0 | private void remCallObj(Long key) {
sync.remove(key);
} |
4f9fd6a9-5b67-49de-bf50-46b9e6e40852 | 5 | final boolean isLoaded(int archiveId, int childId) {
anInt638++;
if (!isValidChild(archiveId, childId))
return false;
if (childBuffers[archiveId] != null && childBuffers[archiveId][childId] != null)
return true;
if (archiveBuffers[archiveId] != null)
return true;
loadArchive(archiveId);
if (archive... |
af1df24e-5ba2-4c9a-a5c8-c2906526bd5b | 3 | public synchronized boolean collect(int id){
while ( buffer[id-1] == null && !faliureDetector.isSuspect(id)){
try{
Utils.out(pid, "waiting for " + id + " "+ faliureDetector.isSuspect(id));
wait();
}catch (InterruptedException e){
Utils.out(pid,"interrupted exception");
}
}
Utils.out(pid,"wait ... |
8c8d971e-1c96-41f8-802c-d9fd690090b5 | 2 | public void addParticleEffect(String effectName, ParticleEffect effect) {
if (effectName == null || effect == null) {
throw new IllegalArgumentException("Cannot add a null ParticleEffect!");
}
particleEffects.put(effectName, effect);
} |
d29333bc-e3b0-49d9-80c8-c0251bcb390c | 1 | public void nextValue() {
value++;
if (value >= values.length) {
value = 0;
}
} |
d0819435-3801-4e49-bb12-85240319e630 | 8 | final public void PackageDeclaration() throws ParseException {
/*@bgen(jjtree) PackageDeclaration */
BSHPackageDeclaration jjtn000 = new BSHPackageDeclaration(JJTPACKAGEDECLARATION);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtreeOpenNodeScope(jjtn000);
try {
jj_consume_token(PACKAGE);
... |
e3361348-8e80-4179-a7cb-6b962135b1f1 | 0 | @Override
public void startSetup(Attributes atts) {
super.startSetup(atts);
addActionListener(this);
} |
4fb348cc-e1b0-40df-9503-cf42e165f9bb | 5 | public static StringBuilder check(String path) {
// TODO Auto-generated method stub
StringBuilder sb = new StringBuilder();
byte[] size = null;
StringBuilder noAlgorithm=new StringBuilder("无法使用MD5算法,这可能是你的JAVA虚拟机版本太低");
StringBuilder fileNotFound=new StringBuilder("未能找到文件,请重新定位文件路径");
StringBuilder IOerror=... |
3c0f9b41-8bb9-4486-ae58-3b597b232cc9 | 1 | @Override
public void train(List<Instance> instances) {
// TODO Auto-generated method stub
// init clusters
for (int i = 0 ; i < clustering_training_iterations ; i++) {
this.EStep(instances);
this.Mstep(instances);
}
} |
7478e7ca-a3af-4b36-9e51-d1bbc4ac6212 | 7 | private boolean fillBuffer(int minimum) throws IOException {
char[] buffer = this.buffer;
lineStart -= pos;
if (limit != pos) {
limit -= pos;
System.arraycopy(buffer, pos, buffer, 0, limit);
} else {
limit = 0;
}
pos = 0;
int total;
while ((total = in.read(buffer, limi... |
e8f3467d-2516-4e22-a996-b1fa1091e434 | 4 | private static void render2D()
{
// Clear the screen and depth buffer
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
for (int k = 0; k < world.getDepth(); k++)
{
for (int i =0; i < world.getWidth(); i++)
{
for (int j = 0; j < world.getHeight(); j++)
{
determineColor(worl... |
de99c582-fb04-433f-9f29-3654c97682cb | 9 | public void execute(ActionInvocation invocation) throws Exception {
long startTime = System.currentTimeMillis();
String location = getStylesheetLocation();
if (parse) {
ValueStack stack = ActionContext.getContext().getValueStack();
location = TextParseUtil.translateVaria... |
a0372299-4aea-4fe7-9e2b-adf089d4f661 | 6 | public BufferedImage yellowHSVFilter(){
this.yellowImage = originalImage;
Color actualPixel;
int actualRedValue;
int actualGreenValue;
int actualBlueValue;
for (int i = 0; i < originalImage.getWidth(); i++) {
for (int j = 0; j < originalImage.getHeight(); j++) {
actualPixel = new Color(originalImage.... |
489072ac-1e86-4afa-9228-4ec95aabf707 | 5 | private static int check(int i, int j, int k, int l, int m){
if(i+j+k+l+m < 792) return Integer.MAX_VALUE;
for(int temp1=0;temp1<5;temp1++){
for(int temp2=temp1+1;temp2<5;temp2++){
if(primeSet.contains(Integer.toString(temp1) + Integer.toString(temp2)) &&
primeSet.contains(Integer.toString(temp2) + Int... |
369509ce-2040-4967-83a3-baadd87e7854 | 7 | private <T extends Enum<? extends IntValueHolder> & IntValueHolder> int getValue(String name, T[] values, int def) {
String prop = props.getProperty(name);
if (prop != null && prop.length() > 0) {
String trimmed = prop.trim();
String[] args = trimmed.split(" ");
int base = 0;
String offset;
if (args.... |
fb0e0060-41ef-4248-83c4-dffcb7991ff0 | 8 | @Test
public void testPathFinding(){
getNewBoard();
// test path to room
List<Square> path = board.getBestPathTo(p3, spa);
if (path.size() != 9){
fail("path size should be 9: " + path.size());
}
// test path is empty if blocked
board.setPlayerPosition(p1, spaEntrance);
path = board.getBestP... |
c9be31d2-75cc-4932-8d49-7d5e159c5ba2 | 2 | public static void unhideCell(BoardModel boardModel, Point position) {
Cell currentCell = boardModel.getBoard()[position.getPosX()][position.getPosY()];
if (currentCell.isMine()) {
boardModel.gameOver();
}
else if (currentCell.isEmpty()) {
unhideNeighborEmptyCell... |
2ae04f97-5e96-4b1a-8fe5-e486bef93cc2 | 3 | public void func_27463_a(Reader var1, J_JsonListener var2) throws J_InvalidSyntaxException, IOException {
J_PositionTrackingPushbackReader var3 = new J_PositionTrackingPushbackReader(var1);
char var4 = (char)var3.read();
switch(var4) {
case 91:
var3.func_27334_a(var4);
var2.fun... |
c98a1070-9997-4a25-b72b-58531320b1a5 | 6 | public int getLoopLength(BrainFuckCode code, boolean forwardSearch) {
int loopLenght = 0;
int numberOfInnerLoops = 0;
int currentPosition = code.getCurrentPosition();
while (currentPosition > 0 && currentPosition < code.getCode().size()) {
Command currentCommand = code.getCo... |
67cab3e2-e239-4470-ae26-ee17451938df | 0 | public void setColor(Color color) {
this.color = color;
} |
56e06b7f-39ce-4801-b7c5-1de8c73141ae | 3 | @Override
public void run() {
DatagramPacket paquete;
byte recibidos[] = new byte[1024];
String IPRemota;
try {
boolean finalizar = false;
while (!finalizar) {
paquete = new DatagramPacket(recibidos, recibidos.length);
socke... |
43ff30cc-e337-42c7-837a-a26313bab203 | 5 | private Map<Integer, List<ServletSource>> groupServicesByPort(
List<ServletSource> services) {
Map<Integer, List<ServletSource>> servicesByPort = new HashMap<Integer, List<ServletSource>>();
for (ServletSource service : services) {
URL url = service.getUrl();
int port = url.getPort();
... |
68d2b88d-fbcb-4839-b952-732a758a23df | 5 | private boolean readRequest(Request request) {
String resource = request.resource;
// Presumption : resource exists.
// try all sites that holds the key.
// There should be at least one site that holds this key.
for (Site site : sitesAvaliable.get(resource)) {
// ch... |
96f8f96d-1b36-4c2f-8fb1-73fa2b4cdcbc | 0 | public void setIdProducto(int idProducto) {
this.idProducto = idProducto;
} |
5e963e5b-9899-45e7-ac95-c09ee62d6632 | 5 | public void removeHost(String name) {
Host h = hosts.remove(name);
boolean disconnectHost = true;
int option = JOptionPane
.showConfirmDialog(
null,
RemoteResourcesLocalization
.getMessage(RemoteResourcesMessages.HostPanel_RemoveHost),
"Remove Host", JOptionPane.YES_NO_OPTION,
... |
ffe03f53-b2ab-4230-8898-1b325392c2fd | 3 | public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Welcome to the Chess Game!");
Scanner inputUser = new Scanner(System.in);
Board myBoard = Board.getmyBoard();
// myBoard.input = inputUser;
myBoard.sortPieces();
myBoard.showBoard();
boolean playerWhoNow = tru... |
507e53bd-7050-4965-a0d0-69b79e9a4a58 | 7 | public PNGDecoder(InputStream input) throws IOException {
this.input = input;
this.crc = new CRC32();
this.buffer = new byte[4096];
readFully(buffer, 0, SIGNATURE.length);
if(!checkSignature(buffer)) {
throw new IOException("Not a valid PNG file");
}
... |
5b655774-e0cb-4341-b776-41670eac8634 | 2 | public static void sumNegativeBalances() {
// External iteration
BigInteger total = BigInteger.ZERO;
for (BankAccount account: christmasBank.getAllAccounts())
if (account.getBalance().signum() < 0)
total = total.add(account.getBalance());
System.out.println("T... |
17e14bd5-cf33-4aaf-94fe-3086607d45c3 | 8 | public static boolean check1DArrayHasAllNumbers(int[] elements,
int boardSize) throws IllegalInput {
int[] numCount = new int[boardSize];
int expectedSum = boardSize * (boardSize + 1) / 2;
if (elements.length != boardSize)
throw new IllegalInput("Board Size is illegal");
for (int i = 0; i < elements.le... |
937740bb-960f-4b4e-9950-ac2e799ae3da | 7 | public LinkedList<ListEmp> getFaults(){
LinkedList<ListEmp> psl = new LinkedList<ListEmp>();
Connection Conn;
ListEmp ps = null;
ResultSet rs = null;
try {
Conn = _ds.getConnection();
} catch (Exception et) {
System.out.println("No connection");
return null;
}
PreparedStatement pmst = null;
... |
fbb313d0-3d64-4682-9062-82fe0b7eeab4 | 1 | public PreferenceLineEnding getLineEnd() {
if (useDocumentSettings()) {
return this.lineEnd;
} else {
return Preferences.getPreferenceLineEnding(Preferences.SAVE_LINE_END);
}
} |
3eea875c-bac5-4a87-a562-a1940fb97b81 | 8 | public void update(Graphics g, JComponent c)
{
boolean divider = c.getName() == null ? false :
c.getName().equals("dividerButton");
if(divider)
{
return;
}
if(c.getHeight() > 255 * 2)
{
return; // exceedingly high component not supported
}
Border bo = null;
int... |
49b93cb4-eff6-4d47-afa0-092df884adcd | 8 | @Override
protected void paintComponent(Graphics g) {
// draw background
g.drawImage(this.imgBackground, 0, 0, null);
// draw pieces
for (FigureGUI guiFigure : this.guiFigures) {
if(!guiFigure.isCaptured()) {
g.drawImage(guiFigure.getImg(), guiFigure.getX(), guiFigure.... |
7f6a832b-7f5c-4243-946e-f69f5d97ecaa | 8 | public boolean loadLevel(String xmlFilePath)
{
try
{
File xmlFile = new File(xmlFilePath);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(xmlFile);
doc.getDocumentElement().normalize();... |
86412812-d76b-4207-9f06-76afdae133fd | 1 | @Override
public void update(int delta) {
for(Entity entity : entities)
entity.update(delta);
} |
942c71e0-7779-4a5c-8ed6-81fa988eafd2 | 8 | private boolean r_postlude() {
int among_var;
int v_1;
// repeat, line 75
replab0: while(true)
{
v_1 = cursor;
lab1: do {
// (, line 75
... |
1ca2b5eb-aaf7-4ea7-8077-fc651c8301ad | 9 | public void buildTree(Instances data, SimpleLinearRegression[][] higherRegressions,
double totalInstanceWeight, double higherNumParameters) throws Exception{
//save some stuff
m_totalInstanceWeight = totalInstanceWeight;
m_train = new Instances(data);
m_isLeaf = true... |
e7bd2b21-c1a9-4f08-a299-0b4c0dd7a606 | 1 | private void setTracking(BoundaryArea tracking) {
if (tracking != mAdjuster) {
mAdjuster = tracking;
Cursor cursor = mAdjuster.getCursor();
mComponent.setCursor(cursor);
WindowUtils.getWindowForComponent(mComponent).setCursor(cursor);
mListener.boundaryAreaChanged(mAdjuster);
}
} |
9f49d599-1103-44c8-9138-7e24c36fb9cf | 4 | public void process() {
// System.out.println("Mapa:");
// for (int i = 2; i <= N; i++) {
// System.out.print(i + "\t");
// }
// System.out.println();
BigDecimal sumaReda;
for (int i = 2; i <= N; i++) {
switch (checkNumber(i)) {
case 1:
// Broj je prim broj
sumaReda = getSumAll(i);
// Sy... |
a95df266-e948-4ce9-9a30-d0018babf138 | 9 | public void makeMove(Player p){
for (BoardCell target : targets) {
target.setTarget(false);
}
rollDie();
startTargets(p.currentIndex, die);
if(p instanceof ComputerPlayer){
humansTurn = false;
ArrayList<BoardCell> roomList = new ArrayList<BoardCell>();
ArrayList<BoardCell> list = new ArrayList<... |
cb61962e-bb27-4846-b7b8-1bc3e2cfbdb8 | 6 | public void doGenerate(){
Random rand = new Random();
StringBuilder sb = new StringBuilder();
roll = (rand.nextInt(100)+1);
if(roll <= 25) {
value = ((rand.nextInt(4)+1)+(rand.nextInt(4)+1)+(rand.nextInt(4)+1)+(rand.nextInt(4)+1));
randGem = tier1[rand.nextInt(tier1.length)];
} else if(roll <= 50)... |
d9fbb150-ae1c-45ab-9e4f-d966d7fe30f6 | 2 | public Object get(String key) throws JSONException {
if (key == null) {
throw new JSONException("Null key.");
}
Object object = this.opt(key);
if (object == null) {
throw new JSONException("JSONObject[" + quote(key) + "] not found.");
}
return obje... |
c244f0dd-1868-46c9-8d56-3d0f0c3b733e | 7 | public String nextString() throws IOException {
int p = peeked;
if (p == PEEKED_NONE) {
p = doPeek();
}
String result;
if (p == PEEKED_UNQUOTED) {
result = nextUnquotedValue();
} else if (p == PEEKED_SINGLE_QUOTED) {
result = nextQuotedValue('\'');
} else if (p == PEEKED_DO... |
f4f9df80-234b-40f8-8d97-84b1a1a0be07 | 9 | public void transferCert(String title, String exe_query, String filter, String table_name) {
DBHandler db = new DBHandler();
String cert_query_where = "";
String cert_query_hint = "";
String cert_query = "";
Pattern pattern = Pattern.compile("where\\s.{1,};$");
Matcher match_regxp = pattern.matcher(ex... |
cfdc0756-bedf-49ae-ab60-d4ee40e2da30 | 1 | private double[] getStatisticalSpectrumDescriptor(double[] dataRow) {
int N = dataRow.length;
double ssd[] = new double[N_STATISTICAL_DESCRIPTORS];
ssd[0] = new Mean().evaluate(dataRow);
ssd[1] = new Variance().evaluate(dataRow);
ssd[2] = new Skewness().evaluate(dataRow);
... |
e9d84ab0-519b-42a9-a275-6f151d3b0a41 | 1 | public int tLineCount(){
int count = item.tLineCount();
if(this.items != null)
count += this.items.tLineCount();
return count;
} |
72a29115-0c43-4838-bbbe-c94c4a38a76d | 2 | public void fixNode (String footpath, pgrid.service.corba.repair.RepairIssue issue)
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("fixNode", true);
$out.write_string (footpath);
pgrid.... |
31b78e76-5ec2-4581-b242-55d4baeced19 | 4 | public String toString() {
String gasStore = " Name: " + name + " (id: " + id + ")" + "\n\n" +
" Address: " + address + "\n" +
" Phone: " + phone + "\n" +
" Brand: " + brand + "\n" +
" Distance: " + distance + " miles... |
08214622-01c2-4a4d-817b-09d4f27f7698 | 1 | public static void awardBonusInternal() {
BigInteger bonusReduction = BigInteger.valueOf(100);
christmasBank.getAllAccounts().parallelStream().
filter(account -> account.getBalance().signum() > 0).
forEach(account -> account.deposit(account.getBalance().divide(bonusReduc... |
92813efb-39bd-47d2-a4ed-13c13dd82d9c | 1 | public AuthFrame(final AuthModule module) {
super("Авторизация", true, false, false, false);
setFrameIcon(Resources.getImageIcon("frame.png"));
setBounds(100, 100, 203, 213);
getContentPane().setLayout(null);
okButton = new JButton("Вход");
okButton.addActionListener(new ActionListener() {
public void... |
ab91dbfd-c33e-4504-948d-40a2b187a83b | 0 | public String[] getElementsInline() {
return this.ELEMENTS_INLINE;
} |
1dacf913-49e4-4a30-8898-1b3c41a93424 | 7 | @Override
public HumanNameDt fromString(HumanNameDt name, String value) {
String[] pcs = value.split("\\,", 2);
String[] pcs1 = pcs[0].split("\\ ");
String[] pcs2 = pcs.length == 1 ? null : pcs[1].split("\\ ");
if (name == null) {
name = new HumanNameDt();
... |
bd192462-c5a4-44c7-ae57-f6f1832828d7 | 4 | public static double erlangBprobabilityNIR(double totalTraffic, double totalResources) {
double prob = 0.0D; // blocking probability
// numerator
double lognumer = totalResources * Math.log(totalTraffic) - totalTraffic;
// denominator (incomplete Gamma Function)
double oneplustr = 1.0D + totalResources;
d... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.