{ "first_submission_id": "sub2", "second_submission_id": "sub1", "match_percentage": 56.33163, "files_of_first_submission": [ { "file_name": "Jumpbox12.java", "lines": [ "package submission.sub2;", "import submission.sub1.Jumpbox11;", "", "import java.util.*;", "import java.awt.*;", "", "public class Jumpbox12 extends Frame implements Runnable {", "", "\tImage smile, nosmile, offImage;", "\tGraphics offGraphics = null;", "\tint sizeImg;", "\tint nrChange = 0, xOldBox, yOldBox, xBox = 0, yBox = 0, typeBox, points = 0, cBox[] = new int[4];", "\tLong gTime;", "\tlong gameTime;", "\tRandom rnd = new Random(System.currentTimeMillis());", "\tThread animationThread;", "\tboolean bSmile, threadRunning = false;", "", "\tpublic Jumpbox12(String title, String[] args) {", "\t\tsuper(title);", "\t\tif (args.length == 0) {", "\t\t\tgameTime = 15;", "\t\t\tgTime = new Long(15);", "\t\t} else {", "\t\t\ttry {", "\t\t\t\tgTime = new Long(args[0]);", "\t\t\t\tgameTime = gTime.longValue();", "\t\t\t} catch (NumberFormatException ioe) {", "\t\t\t\tSystem.out.println(\"Jumpbox: usage: Jumpbox \");", "\t\t\t\tSystem.exit(0);", "\t\t\t}", "\t\t}", "", "\t\tgameTime = System.currentTimeMillis() + gameTime*1000;", "", "\t\tToolkit toolkit = Toolkit.getDefaultToolkit();", "\t\tsmile = toolkit.getImage(\"smile.gif\");", "\t\tnosmile = toolkit.getImage(\"wince.gif\");", "", "\t\trandomBoxColor();", "\t\trandomBoxType();", "\t\trandomBoxCoordinates();", "\t}", "", "\tprivate void startThread() {", "\t\tanimationThread = new Thread(this);", "\t\tanimationThread.start();", "\t}", "", "\tpublic void run() {", "\t\tthreadRunning = true;", "\t\tnrChange++;", "\t\tif (nrChange >= 3) {", "\t\t\tnrChange = 0;", "\t\t\trandomBoxColor();", "\t\t}", "\t\tif (bSmile) { \t\t\t// SMILE", "\t\t\tdrawSmile(this.getGraphics(), xBox, yBox);", "\t\t\ttry {", "\t\t\t\tanimationThread.sleep(500);", "\t\t\t} catch (InterruptedException ignored) {", "", "\t\t\t}", "\t\t\tpoints++;", "\t\t} else { \t\t\t\t// NO SMILE", "\t\t\tsizeImg = 26;", "\t\t\twhile (sizeImg > 1) {", "\t\t\t\tsizeImg--;", "\t\t\t\trepaint();", "\t\t\t\ttry {", "\t\t\t\t\tanimationThread.sleep(40);", "\t\t\t\t} catch (InterruptedException ignored) {", "\t\t\t\t}", "\t\t\t}", "\t\t\tpoints--;", "\t\t}", "\t\trandomBoxCoordinates();", "\t\trandomBoxType();", "\t\tdrawLine(this.getGraphics(), xOldBox, yOldBox, xBox, yBox);", "\t\ttry {", "\t\t\tanimationThread.sleep(500);", "\t\t} catch (InterruptedException ignored) {\t\t}", "\t\tdeleteBox(this.getGraphics(), xOldBox, yOldBox);", "\t\tdeleteLine(this.getGraphics(), xOldBox, yOldBox, xBox, yBox);", "\t\tdrawBox(this.getGraphics(), xBox, yBox, cBox[typeBox]);", "\t\tthreadRunning = false;", "\t\trepaint();", "\t\tanimationThread.yield();", "\t}", "", "\tpublic void update(Graphics g) {", "\t\tif (threadRunning) {", "\t\t\tif (bSmile) {", "\t\t\t\tpaint(g);", "\t\t\t} else { // Animation NoSmile", "\t\t\t\tif (offGraphics == null) {", "\t\t\t\t\toffImage = createImage(50,50);", "\t\t\t\t\toffGraphics = offImage.getGraphics();", "\t\t\t\t}", "\t\t\t\toffGraphics.setColor(getBackground());", "\t\t\t\toffGraphics.fillRect(0,0,50,50);", "\t\t\t\toffGraphics.drawImage(nosmile,25-sizeImg,25-sizeImg,sizeImg*2,sizeImg*2, this);", "\t\t\t\tg.drawImage(offImage, xBox, yBox, this);", "\t\t\t}", "\t\t} else {", "\t\t\tpaint(g);", "\t\t}", "\t}", "", "\tpublic void paint(Graphics g) {", "\t\tg.setColor(number2color(cBox[0]));", "\t\tg.fillRect(0,0,50,50);", "\t\tg.setColor(number2color(cBox[1]));", "\t\tg.fillRect(50,0,50,50);", "\t\tg.setColor(number2color(cBox[2]));", "\t\tg.fillRect(100,0,50,50);", "\t\tg.setColor(number2color(cBox[3]));", "\t\tg.fillRect(150,0,50,50);", "", "\t\tg.setColor(Color.black);", "\t\tg.drawString(\"L\", 24, 27);", "\t\tg.drawString(\"R\", 74, 27);", "\t\tg.drawString(\"O\", 124, 27);", "\t\tg.drawString(\"U\", 174, 27);", "", "\t\tg.setColor(Color.white);", "\t\tg.drawRect(0,49,499,400-49);", "", "\t\tdrawBox(g, xBox, yBox, cBox[typeBox]);", "\t}", "", "\tprivate boolean inBox(int x, int y) {", "\t\tif ((x >= xBox) && (y >= yBox) && (x <= xBox+50) && (y <= yBox+50))", "\t\t\treturn true;", "\t\telse", "\t\t\treturn false;", "\t}", "", "\tprivate boolean inBigBox(int x, int y) {", "\t\tif ((x >= xBox-50) && (y >= yBox-50) && (x <= xBox+100) && (y <= yBox+100))", "\t\t\treturn true;", "\t\telse", "\t\t\treturn false;", "\t}", "", "\tprivate boolean inEntre(int box, int x, int y) {", "\t\tswitch(box) {", "\t\t\tcase 0: if ((x < xBox) && !((y < yBox) || (y > yBox +50))) return true; break;", "\t\t\tcase 1: if ((x > xBox + 50) && !((y < yBox) || (y > yBox +50))) return true; break;", "\t\t\tcase 2: if ((y < yBox) && !((x < xBox) || (x > xBox +50))) return true; break;", "\t\t\tcase 3: if ((y > yBox + 50) && !((x < xBox) || (x > xBox +50))) return true; break;", "\t\t}", "\t\treturn false;", "\t}", "", "\tprivate void randomBoxCoordinates() {", "\t\txOldBox = xBox;", "\t\tyOldBox = yBox;", "\t\txBox = (int)(rnd.nextFloat() * 449) + 1;", "\t\tyBox = (int)(rnd.nextFloat() * 300) + 50;", "\t\twhile ( ((xBox > xOldBox-50) && (xBox < xOldBox+100)) && ((yBox > yOldBox-50) && (yBox < yOldBox+100)) ) {", "\t\t\txBox = (int)(rnd.nextFloat() * 449) + 1;", "\t\t\tyBox = (int)(rnd.nextFloat() * 300) + 50;", "\t\t}", "\t}", "", "\tprivate void drawBox(Graphics g, int x, int y, int c) {", "\t\tg.setColor(number2color(c));", "\t\tg.fillRect(x, y, 50, 50);", "\t}", "", "\tprivate void deleteBox(Graphics g, int x, int y) {", "\t\tg.setColor(Color.gray);", "\t\tg.fillRect(x, y, 50, 50);", "\t}", "", "\tprivate void randomBoxType() {", "\t\twhile ((typeBox = (int)(rnd.nextFloat()*4)) == 4) {}", "\t}", "", "\tprivate void drawLine(Graphics g, int xOld, int yOld, int x, int y) {", "\t\tg.setColor(Color.white);", "\t\tg.drawLine(xOld + 25, yOld + 25, x + 25, y + 25);", "\t}", "", "\tprivate void deleteLine(Graphics g, int xOld, int yOld, int x, int y) {", "\t\tg.setColor(Color.gray);", "\t\tg.drawLine(xOld + 25, yOld + 25, x + 25, y + 25);", "\t}", "", "\tprivate void drawSmile(Graphics g, int xOld, int yOld) {", "\t\tg.drawImage(smile, xOld, yOld, this);", "\t}", "", "\tpublic boolean mouseDrag(Event evt, int x, int y) {", "\t\treturn mouseMove(evt, x,y);", "\t}", "", "\tpublic boolean mouseMove(Event evt, int x, int y) {", "\t\tif (gameTime < System.currentTimeMillis()) {", "\t\t\tSystem.out.println(\"Ergebnis: \" + points + \" Punkte in \" + gTime.longValue() + \" Sekunden.\");", "\t\t\tSystem.exit(0);", "\t\t\treturn true;", "\t\t}", "\t\tif (!threadRunning) {", "\t\t\tif (inBox(x,y)) {", "\t\t\t\tbSmile = true;", "\t\t\t\tstartThread();", "\t\t\t}", "\t\t\telse if ((inBigBox(x,y)) && !(inEntre(typeBox, x, y))) {", "\t\t\t\tbSmile = false;", "\t\t\t\tstartThread();", "\t\t\t}", "\t\t}", "\t\treturn true;", "\t}", "", "\tpublic boolean handleEvent(Event e) {", "\t\tswitch (e.id) {", "\t\t\tcase Event.WINDOW_ICONIFY:", "\t\t\t\tbreak;", "\t\t\tcase Event.WINDOW_DEICONIFY:", "\t\t\t\trepaint();", "\t\t\t\tbreak;", "\t\t\tcase Event.WINDOW_DESTROY:", "\t\t\tSystem.exit(0);", "\t\t\tbreak;", "\t\t}", "\t\treturn super.handleEvent(e);", "\t}", "", "\tprivate Color number2color(int i) {", "\t\tswitch(i) {", "\t\t\tcase 1: return Color.blue;", "\t\t\tcase 2: return Color.cyan;", "\t\t\tcase 3: return Color.green;", "\t\t\tcase 4: return Color.magenta;", "\t\t\tcase 5: return Color.orange;", "\t\t\tcase 6: return Color.pink;", "\t\t\tcase 7: return Color.red;", "\t\t\tcase 8: return Color.yellow;", "\t\t}", "\t\treturn Color.white;", "\t}", "", "\tprivate void randomBoxColor() {", "\t\tboolean cCorrect;", "\t\tint i = 0, c;", "\t\twhile (i < 4) {", "\t\t\tc = (int)(rnd.nextFloat()*8 + 1);", "\t\t\tcBox[i] = c;", "\t\t\tcCorrect = true;", "\t\t\tif (cBox[i] == 9)", "\t\t\t\tcCorrect = false;", "\t\t\telse {", "\t\t\t\tfor (int j=0;j < i; j++) {", "\t\t\t\t\tif (cBox[i] == cBox[j])", "\t\t\t\t\t\tcCorrect = false;", "\t\t\t\t}", "\t\t\t}", "\t\t\tif (cCorrect)", "\t\t\t\ti++;", "\t\t}", "\t\t}", "", "\tstatic public void main(String[] args) {", "\t\tFrame f = new Jumpbox11(\"Jumpbox - Xxxx Xxxxxx, #942261\", args);", "\t\tf.setBackground(Color.gray);", "\t\tf.resize(508,430);", "\t\tf.show();", "\t}", "}" ] }, { "file_name": "Jumpbox22.java", "lines": [ "package submission.sub2;", "/* Synchonisationen sind in diesem Applet nicht notwendig, da durch das", " gegenseitige Warteverhalten sichergestellt ist, dass immer nur ein Thread", " zeichnen kann.", " */", "", "import java.awt.*;", "import java.applet.*;", "import java.util.*;", "", "public class Jumpbox22 extends Applet implements Runnable{", "\tstatic boolean AppletCanStart=false;", "\tstatic Image vImg=null;", "\tstatic Graphics vG;", "\tstatic Image GrinsAnim[]=new Image[1];", "\tstatic Image GrummelAnim[]=new Image[25];", "\tstatic Thread animThread;", "\tstatic Color ColorList[]={Color.blue,Color.cyan,Color.green,Color.magenta,Color.orange,Color.pink,Color.red,Color.yellow};", "\tstatic boolean boolColorListFlags[]=new boolean[ColorList.length];", "\tstatic Color RBoxFarben[]=new Color[4];", "\tstatic Random RND=new Random(System.currentTimeMillis());", "\tstatic long StartTime;", "\tstatic long EndTime=15000;", "\tstatic String Zeit=\"15\";", "\tstatic int Points=0;", "\tstatic int DstXBox,DstYBox,DstRichtung;", "\tstatic Applet applet;", "\tstatic int AnimXPos,AnimYPos;", "\tstatic Image Animation[];", "\tstatic long AnimMSPF;", "\tstatic boolean NoMouse=true;", "\tstatic int LastXMouse=0,LastYMouse=0;", "", "\tpublic void init(){ // Init. fuer Hauptprogramm und animThread", "\t\tanimThread=new Thread(this);", "\t\tMediaTracker tracker=new MediaTracker(this);", "\t\tGrinsAnim[0]=Toolkit.getDefaultToolkit().getImage(\"smile.gif\");", "\t\ttracker.addImage(GrinsAnim[0],0);", "\t\tfor(int i=0;i<25;i++){", "\t\t\tGrummelAnim[i]=Toolkit.getDefaultToolkit().getImage(\"grumel\"+i+\".gif\");", "\t\t\ttracker.addImage(GrummelAnim[i],0);", "\t\t}", "\t\ttry{", "\t\t\ttracker.waitForID(0);", "\t\t} catch (InterruptedException e){", "\t\t}", "\t}", "", "\tpublic Dimension preferredSize(){", "\t\treturn new Dimension(500,400);", "\t}", "", "\tprotected void mouseAction(int x,int y){", "\t\tLastXMouse=x;", "\t\tLastYMouse=y;", "\t\tif (System.currentTimeMillis()>=EndTime)", "\t\t\tsynchronized(applet){", "\t\t\t\tapplet.notify();", "\t\t\t}", "\t\tif (NoMouse)", "\t\t\treturn;", "\t\tRectangle BBox=new Rectangle(DstXBox-50,DstYBox-50,150,150);", "\t\tif (!BBox.inside(x,y))", "\t\t\treturn;", "\t\tBBox.reshape(DstXBox,DstYBox,50,50);", "\t\tif (BBox.inside(x,y)){", "\t\t\tNoMouse=true;", "\t\t\tPoints++;", "\t\t\tsetAnimParams(DstXBox,DstYBox,GrinsAnim,500);", "\t\t\treturn;", "\t\t}", "\t\tBBox.move((DstRichtung<2)?DstXBox+DstRichtung*100-50:DstXBox,", "\t\t\t\t(DstRichtung>1)?DstYBox+(DstRichtung-2)*100-50:DstYBox);", "\t\tif (BBox.inside(x,y))", "\t\t\treturn;", "\t\tNoMouse=true;", "\t\tPoints--;", "\t\tsetAnimParams(DstXBox,DstYBox,GrummelAnim,40);", "\t}", "", "\tpublic boolean mouseDrag(Event evt,int x,int y){ // Maus mit Taste", "\t\tmouseAction(x,y);", "\t\treturn true;", "\t}", "", "\tpublic boolean mouseMove(Event evt,int x,int y){ // Maus ohne Taste", "\t\tmouseAction(x,y);", "\t\treturn true;", "\t\t}", "", "\tpublic void MischeRichtungen(){", "\t\tint i,idx;", "\t\tfor(i=0;i0){", "\t\t\t\tSpringe();", "\t\t\t} else", "\t\t\t\tGenNewBox();", "\t\t\tvG.setColor(RBoxFarben[DstRichtung]);", "\t\t\tvG.fillRect(DstXBox,DstYBox,50,50);", "\t\t\trepaint();", "\t\t\tNoMouse=false;", "\t\t\ttry{", "\t\t\t\tsynchronized(applet){", "\t\t\t\t\tapplet.wait();", "\t\t\t\t}", "\t\t\t} catch (InterruptedException ie){", "\t\t\t}", "\t\t\tDurchlauf++;", "\t\t} while(System.currentTimeMillis()0)", "\t\t\t\t\ttry{", "\t\t\t\t\t\tThread.sleep(DiffPeriod);", "\t\t\t\t\t} catch (InterruptedException ie){", "\t\t\t\t\t}", "\t\t\t}", "\t\t\tsynchronized(applet){", "\t\t\t\tapplet.notify();", "\t\t\t}", "\t\t}", "\t}", "", "\tpublic void paint(Graphics g){ // Paint von Applet", "\t\tupdate(g);", "\t}", "", "\tpublic void update(Graphics g){ // Update von Applet", "\t\tif (vImg==null){", "\t\t\tvImg=createImage(500,400);", "\t\t\tvG=vImg.getGraphics();", "\t\t\tvG.setColor(Color.gray);", "\t\t\tvG.fillRect(0,0,500,400);", "\t\t\tvG.setColor(Color.white);", "\t\t\tvG.drawRect(0,50,500-1,350-1);", "\t\t\tAppletCanStart=true;", "\t\t}", "\t\tg.drawImage(vImg,0,0,this);", "\t}", "", "\tpublic static void main(String args[]){ // Start von Jumpbox", "\t\t// Kommandozeilen-Argumente auswerten", "\t\tif (args.length>1){", "\t\t\tSystem.out.println(\"Usage: java Jumpbox \");", "\t\t\tSystem.exit(0);", "\t\t} else if (args.length==1){", "\t\t\tZeit=args[0];", "\t\t\tEndTime=(new Long(Zeit)).longValue()*1000;", "\t\t}", "\t\t// Applet ausfuehren", "\t\tapplet=new Jumpbox22();", "\t\tapplet.init();", "\t\tFrame frame=new Frame(\"Xxxxxxx Xxxx, #791299\");", "\t\tframe.setResizable(false);", "\t\tframe.add(\"Center\",applet);", "\t\tframe.pack();", "\t\tframe.show();", "\t\twhile (!AppletCanStart)", "\t\t\ttry{", "\t\t\t\tThread.sleep(100);", "\t\t\t} catch (InterruptedException ie){", "\t\t\t}", "\t\tanimThread.start();", "\t\tapplet.start();", "\t}", "", "}" ] } ], "files_of_second_submission": [ { "file_name": "Jumpbox11.java", "lines": [ "package submission.sub1;", "import java.util.*;", "import java.awt.*;", "", "public class Jumpbox11 extends Frame implements Runnable {", "", "\tImage smile,wince,offImage;", "\tint count = 0,size,xO,yO,xB,yB,currentBox,result=0,colors[]=new int[4];", "\tLong tempTime;", "\tlong gameTime;", "\tRandom random = new Random();", "\tThread animationThread;", "\tGraphics offGraphics=null;", "\tboolean happyFace,threadOn=false;", "", "\tpublic Jumpbox11(String title, String[] args) {", "\t\tsuper(title);", "", "\t\tif (args.length == 0){", "\t\t\ttempTime = new Long(\"15\");", "\t\t\tgameTime = 15;", "\t\t}", "\t\telse {", "\t\t\ttry {", "\t\t\t\ttempTime = new Long(args[0]);", "\t\t\t\tgameTime = tempTime.longValue();", "\t\t\t} catch (NumberFormatException ioe) {", "\t\t\t\tSystem.out.println(\"ERROR: usage: Jumpbox \");", "\t\t\t\tSystem.exit(0);", "\t\t\t}", "\t\t}", "", "\t\tgameTime = System.currentTimeMillis() + gameTime*1000;", "", "\t\tToolkit toolkit = Toolkit.getDefaultToolkit();", "\t\tsmile = toolkit.getImage(\"smile.gif\");", "\t\twince = toolkit.getImage(\"wince.gif\");", "", "\t\tsetColors();", "\t\trandomBox();", "\t\trandomCoord();", "\t}", "", "", "\tpublic void run(){", "\t\tthreadOn=true;", "\t\tcount++;", "\t\tif (happyFace){", "\t\t\trepaint();", "\t\t\ttry{", "\t\t\t\tanimationThread.sleep(500);", "\t\t\t} catch (InterruptedException e) {}", "\t\t\tresult++;", "\t\t}", "\t\telse{", "\t\t\tfor(size =25;size>0;size--){", "\t\t\t\trepaint();", "\t\t\t\ttry {", "\t\t\t\t\tanimationThread.sleep(40);", "\t\t\t\t} catch (InterruptedException e) {", "\t\t\t\t\tcontinue;", "\t\t\t\t}", "\t\t\t}", "\t\t\tresult--;", "\t\t}", "\t\trandomCoord();", "\t\trandomBox();", "\t\tdrawLine(this.getGraphics(), xO, yO, xB, yB);", "\t\ttry {", "\t\t\tanimationThread.sleep(500);", "\t\t} catch (InterruptedException e) {}", "\t\tdeleteBox(this.getGraphics(), xO, yO);", "\t\tdeleteLine(this.getGraphics(),xO,yO,xB,yB);", "\t\tif (count >= 3) {", "\t\t\tcount = 0;", "\t\t\tsetColors();", "\t\t\trepaint(0,0,200,50);", "\t\t}", "\t\tdrawBox(this.getGraphics(), xB, yB, colors[currentBox]);", "\t\tthreadOn=false;", "\t\trepaint();", "\t\tanimationThread.yield();", "\t}", "", "\tpublic void update(Graphics g) {", "\t\tif (offGraphics == null) {", "\t\t\toffImage = createImage(50,50);", "\t\t\toffGraphics = offImage.getGraphics();", "\t\t}", "\t\tif (threadOn) {", "\t\t\tif (happyFace) {", "\t\t\t\tg.drawImage(smile,xB,yB,this);", "\t\t\t} else {", "\t\t\t\toffGraphics.setColor(Color.gray);", "\t\t\t\toffGraphics.fillRect(0,0,50,50);", "\t\t\t\toffGraphics.drawImage(wince,25-size,25-size,size*2,size*2, this);", "\t\t\t\tg.drawImage(offImage,xB,yB,this);", "\t\t\t}", "\t\t} else {", "\t\t\tpaint(g);", "\t\t}", "\t}", "", "\tpublic void paint(Graphics g) {", "\t\tg.setColor(returnColor(colors[0]));", "\t\tg.fillRect(0,0,50,50);", "\t\tg.setColor(returnColor(colors[1]));", "\t\tg.fillRect(50,0,50,50);", "\t\tg.setColor(returnColor(colors[2]));", "\t\tg.fillRect(100,0,50,50);", "\t\tg.setColor(returnColor(colors[3]));", "\t\tg.fillRect(150,0,50,50);", "", "\t\tg.setColor(Color.black);", "\t\tg.drawString(\"L\", 24, 27);", "\t\tg.drawString(\"R\", 74, 27);", "\t\tg.drawString(\"O\", 124, 27);", "\t\tg.drawString(\"U\", 174, 27);", "", "\t\tg.setColor(Color.white);", "\t\tg.drawRect(0,50,498,349);", "", "\t\tdrawBox(g, xB, yB, colors[currentBox]);", "\t}", "", "\tpublic boolean inB(int x, int y) {", "\t\tif ((x >= xB) && (y >= yB) && (x <= xB+50) && (y <= yB+50))", "\t\t\treturn true;", "\t\telse", "\t\t\treturn false;", "\t}", "", "\tpublic boolean inIntim(int x, int y) {", "\t\tif ((x >= xB-50) && (y >= yB-50) && (x <= xB+100) && (y <= yB+100))", "\t\t\treturn true;", "\t\telse", "\t\t\treturn false;", "\t}", "", "\tpublic boolean rightIntim(int box, int x, int y) {", "\t\tswitch(box) {", "\t\t\tcase 0: if ((x < xB) && ((y > yB) && (y < yB +50)))", "\t\t\t\treturn true;", "\t\t\t\tbreak;", "\t\t\tcase 1: if ((x > xB + 50) && ((y > yB) && (y < yB +50)))", "\t\t\t\treturn true;", "\t\t\t\tbreak;", "\t\t\tcase 2: if ((y < yB) && ((x > xB) && (x < xB +50)))", "\t\t\t\treturn true;", "\t\t\t\tbreak;", "\t\t\tcase 3: if ((y > yB + 50) && ((x > xB) && (x < xB +50)))", "\t\t\t\treturn true;", "\t\t\t\tbreak;", "\t\t}", "\t\treturn false;", "\t}", "", "\tprivate void randomCoord() {", "\t\txO = xB;", "\t\tyO = yB;", "", "\t\t// Schleife so dass der neue Box nicht entsteht zu nah zu den alten.", "", "\t\twhile(((-50=B.x) && (M.x=B.y) && (M.y