id
stringlengths
36
36
text
stringlengths
1
1.25M
b7fdbfa0-769a-4a8e-8abe-6b3c48f0a017
private static ArrayList<String> generateList() { ArrayList<String> temp = new ArrayList<String>(); temp.add("PC1:\n Bin: " + PC1 + "\n Hex: " + binaryToHex(PC1) + "\n\n"); temp.add("C0:\n Bin: " + C0 + "\n Hex: " + binaryToHex(C0) + "\n\n"); temp.add("D0:\n Bin: " + D0 + "\n Hex: " + binaryToHex(D0) + "\n\n"); temp.add("C1:\n Bin: " + C1 + "\n Hex: " + binaryToHex(C1) + "\n\n"); temp.add("D1:\n Bin: " + D1 + "\n Hex: " + binaryToHex(D1) + "\n\n"); temp.add("Key(PC2):\n Bin: " + keyBin + "\n Hex: " + binaryToHex(keyBin) + "\n\n"); temp.add("L0:\n Bin: " + L0 + "\n Hex: " + binaryToHex(L0) + "\n\n"); temp.add("R0:\n Bin: " + R0 + "\n Hex: " + binaryToHex(R0) + "\n\n"); temp.add("E[R0]:\n Bin: " + ER0 + "\n Hex: " + binaryToHex(ER0) + "\n\n"); temp.add("E[R0] XOR Key (A):\n Bin: " + ERxorK + "\n Hex: " + binaryToHex(ERxorK) + "\n\n"); temp.add("S-Box output (B):\n Bin: " + B + "\n Hex: " + binaryToHex(B) + "\n\n"); temp.add("P(B):\n Bin: " + PB + "\n Hex: " + binaryToHex(PB) + "\n\n"); temp.add("P(B) XOR L0 (R1):\n Bin: " + messageBin + "\n Hex: " + binaryToHex(messageBin) + "\n\n"); return temp; }
8f2f98e2-d95a-4531-8fa1-861cd5d7bc95
private static void generateKey() { keyBin = pad(keyBin); PC1 = permute(keyBin,DESConstants.PC1Order); C0 = PC1.substring(0,28); C1 = PC1.substring(1,28) + PC1.charAt(0); D0 = PC1.substring(28,56); D1 = PC1.substring(29,56) + PC1.charAt(28); keyBin = permute(C1+D1,DESConstants.PC2Order); }
6b17dc2d-ff20-4082-9386-a46f32cfb2ed
private static String permute(String initial, int[] order) { String out = ""; for (int i = 0; i < order.length; i++) { out += initial.charAt(order[i]-1); } return out; }
7f7328b3-1d76-4ee2-b3b7-d626a0fa3f98
private static void generateMessage() { L0 = permute(messageBin,DESConstants.L0Order); R0 = permute(messageBin,DESConstants.R0Order); ER0 = eTable(); ERxorK = xor(ER0,keyBin); B = sboxSubstitution(); PB = permute(B,DESConstants.Permute); messageBin = xor(PB,L0); }
574e3821-b2eb-4085-8511-4ab5d382fb64
private static String sboxSubstitution() { String[][] data = new String[9][4]; data[0][0] = "6-bit from A"; data[0][1] = "(b2, b3, b4, b5)"; data[0][2] = "(column) in base 10"; data[0][3] = "In base 2"; String out = ""; int row, column, bounds = 0; String bits = ""; for(int i = 0; i < DESConstants.SBox.size(); i++) { bits = ERxorK.substring(bounds, bounds+6); data[i+1][0] = bits; row = Integer.parseInt(""+bits.charAt(0)+bits.charAt(5),2); column = Integer.parseInt(bits.substring(1,5),2); data[i+1][1] = bits.substring(1,5); data[i+1][2] = Integer.toString(DESConstants.SBox.get(i)[row][column]); data[i+1][3] = String.format("%4s",Integer.toBinaryString(DESConstants.SBox.get(i)[row][column])).replace(' ','0'); out += String.format("%4s",Integer.toBinaryString(DESConstants.SBox.get(i)[row][column])).replace(' ','0'); bounds += 6; } SpreadSheet ss = new SpreadSheet(data); JFrame jF = new JFrame(); jF.add(ss); jF.setSize(800, 600); jF.setTitle("S-Box Output"); jF.setVisible(true); return out; }
e719811f-06c1-47d8-938d-dbfac5802dea
private static String eTable() { String out = ""; out = R0.charAt(31) + R0.substring(0,4) + R0.charAt(4); out += R0.charAt(3) + R0.substring(4,8) + R0.charAt(8); out += R0.charAt(7) + R0.substring(8,12) + R0.charAt(12); out += R0.charAt(11) + R0.substring(12,16) + R0.charAt(16); out += R0.charAt(15) + R0.substring(16,20) + R0.charAt(20); out += R0.charAt(19) + R0.substring(20,24) + R0.charAt(24); out += R0.charAt(23) + R0.substring(24,28) + R0.charAt(28); out += R0.charAt(27) + R0.substring(28,32) + R0.charAt(0); return out; }
e9fdbb4e-4075-47b1-b2fb-cecfd2b9ccd9
public static String getKeyHex() { return binaryToHex(keyBin); }
7eab6bab-a9b4-4a11-b345-32055542e433
public static String getMessageHex() { return binaryToHex(messageBin); }
58e149f9-9f6f-4898-8a52-d642888211d2
public static String getKeyBin() { return keyBin; }
d0161188-a182-4035-881f-4874eb9018fe
public static String getMessageBin() { return messageBin; }
63b029f3-aafc-4464-8054-4eacf0d68047
private static String binaryToHex(String binary) { String out = ""; for(int i = 0; i < binary.length(); i+=4) { out += Integer.toHexString(Integer.parseInt(binary.substring(i,i+4),2)).toUpperCase(); } return out; }
cbdc439c-ef4b-4b0e-8552-a6c7497873c1
private static String hexToBinary(String hex) { String out = ""; for (int i = 0; i < hex.length(); i++) { out += String.format("%4s",Integer.toBinaryString(Integer.parseInt("" + hex.charAt(i),16))).replace(' ','0'); } return out; }
f7581a66-564b-4665-8e81-138088cbf2b0
private static String alphaToBinary(String alpha) { String returnString = ""; for(int i = 0; i < alpha.length(); i++) { switch(alpha.charAt(i)) { case 'a': returnString += '0'; break; case 'b': returnString += '1'; break; case 'c': returnString += '2'; break; case 'd': returnString += '3'; break; case 'e': returnString += '4'; break; case 'f': returnString += '5'; break; case 'g': returnString += '6'; break; case 'h': returnString += '7'; break; case 'i': returnString += '8'; break; case 'j': returnString += '9'; break; case 'r': returnString += '9'; break; case 'k': returnString += 'A'; break; case 'l': returnString += 'B'; break; case 'm': returnString += 'C'; break; case 'n': returnString += 'D'; break; case 'o': returnString += 'E'; break; case 'p': returnString += 'F'; break; } } return hexToBinary(returnString); }
d52fe8c0-299a-4771-9d2c-3528158f4bdc
private static String xor(String binary1, String binary2) { String out = ""; for(int i = 0; i < binary1.length(); i++) { out += (binary1.charAt(i) == binary2.charAt(i))?("0"):("1"); } return out; }
4444586e-606a-4897-82ac-1033fc94d3f5
private static String convert(String s) { s = s.replaceAll(" ", ""); if(s.length() > 16) return s; else { // Alpha if(s.toLowerCase().equals(s)) return alphaToBinary(s); // Hex else return hexToBinary(s); } }
01c091dd-a261-49fe-b1fa-556e1a18eafa
private static String pad(String s) { while(s.length() < 64) s = '0' + s; return s; }
e1284301-a460-4b42-be49-145cfc976a0e
public OrderLine() { }
43d28105-8dff-4349-bf34-4103cbd2ee2c
public OrderLine(int quantity) { super(); this.quantity = quantity; }
bcc072ac-f02c-48f9-83aa-1482d0114753
public Customer(int id, String firstName, String lastName) { super(); this.id = id; this.firstName = firstName; this.lastName = lastName; }
e3059813-2f94-48f5-b164-96e55961f104
public int getId() { return id; }
ca6a068d-3747-4e27-afcd-8ccb1105c701
public void setId(int id) { this.id = id; }
8159dcb3-42ce-4491-a431-48b4e4296d8b
public String getFirstName() { return firstName; }
15bf421b-e719-484d-ac3d-0ddfeb077195
public void setFirstName(String firstName) { this.firstName = firstName; }
01549adf-f741-42fe-af8d-d0ac204bdb32
public String getLastName() { return lastName; }
3e6a06d0-c753-40ea-a56e-6a4844cb9af4
public void setLastName(String lastName) { this.lastName = lastName; };
a2057e68-1132-484a-921f-3979ce3c52b8
public DVD(String name, String description, String genre) { super(name, description); this.genre = genre; }
e08ed54d-10ce-442c-b78d-f9f6d60dbd44
public DVD() { super(); }
c93ca430-1d3a-48b5-87d5-8e57acaf8284
public DVD(String genre) { super(); this.genre = genre; }
80c2334e-1083-495c-9973-901775d8c7db
public CD() { }
98b3c5c4-c374-49a4-8ab5-2f6f9801c9c8
public CD(String artist, String name, String description) { super(name, description); this.artist = artist; }
6f400189-0696-45af-89fd-7f085fcfbd78
public static void main(String[] args) { // Hibernate placeholders Session session = null; Transaction tx = null; try { session = sessionFactory.openSession(); tx = session.beginTransaction(); // Create new instance of Car and set values in it Product pro = new CD("Ying", "Ying", "A good stuff"); OrderLine oLine = new OrderLine(8); pro.setOrderLine(oLine); session.persist(pro); pro = new DVD("Huang", "Ying", "A good stuff"); pro.setOrderLine(oLine); session.persist(pro); pro = new Book("huangyingw", "Ying", "A good stuff"); session.persist(pro); tx.commit(); } catch (HibernateException e) { tx.rollback(); e.printStackTrace(); } finally { if (session != null) session.close(); } try { session = sessionFactory.openSession(); tx = session.beginTransaction(); List<Product> proList = session.createQuery("from Product").list(); for (Product pro : proList) { System.out.println(pro.getName()); } tx.commit(); } catch (HibernateException e) { tx.rollback(); e.printStackTrace(); } finally { if (session != null) session.close(); } // Close the SessionFactory (not mandatory) sessionFactory.close(); }
bd819c43-b2f6-45a8-8ae7-820b38fb6bc4
public int getId() { return id; }
65ba0af3-18c9-4b5e-b0d2-1016e481d3d7
public void setId(int id) { this.id = id; }
7e2c89ae-31bf-448c-8988-d6fa6284e295
public String getName() { return name; }
267960b1-787e-486a-8bc7-ff4eb86a0356
public void setName(String name) { this.name = name; }
d9af2226-f7b9-4e48-b14b-c2da38bbd4f0
public String getDescription() { return description; }
1c9cf540-6412-439c-b890-60788bfbf2f2
public void setDescription(String description) { this.description = description; }
a5065d6d-94c8-40f6-9086-a3532096389a
public OrderLine getOrderLine() { return orderLine; }
2f609565-3d19-4b3d-bec5-61287bb678ef
public void setOrderLine(OrderLine orderLine) { this.orderLine = orderLine; }
db8f9060-67c0-4142-9577-3fa46594154e
public Product() { }
841a8c87-e8e2-4623-891e-4ca3372052c4
public Product(String name, String description) { super(); this.name = name; this.description = description; }
c508234f-3ccc-49f0-8ec9-c4a8f9d774f5
public Book() { super(); }
da500861-4a21-4d3c-933d-990d19b485b6
public Book(String name, String description, String title) { super(name, description); this.title = title; }
fbc90ef7-8c3b-40fd-9df4-92cbeea287f1
public Order(int orderid, Date date) { super(); this.orderid = orderid; this.date = date; }
fad89e54-7f12-4600-8b78-5ba87203df99
public int getOrderid() { return orderid; }
36284aad-f9b1-4d54-8195-a06ec8cc6688
public void setOrderid(int orderid) { this.orderid = orderid; }
d3ca8e86-7112-4a02-9ccc-41f2be9b0032
public Date getDate() { return date; }
a8084d3e-cbde-42db-b3c2-c18e8bcfb482
public void setDate(Date date) { this.date = date; }
73ac728a-91c4-4130-af83-ac1b017153ba
public static int minimum(int a, int b, int c) { return Math.min(Math.min(a, b), c); }
8fae88e1-9822-4d69-b459-1f6ed42d7581
public IntWritable evaluate(Text col1, Text col2) { if (col1 == null || col2 == null) { return null; } String str1 = col1.toString(); String str2 = col2.toString(); int[][] distance = new int[str1.length() + 1][str2.length() + 1]; for (int i = 0; i <= str1.length(); i++) distance[i][0] = i; for (int j = 1; j <= str2.length(); j++) distance[0][j] = j; for (int i = 1; i <= str1.length(); i++) for (int j = 1; j <= str2.length(); j++) distance[i][j] = minimum( distance[i - 1][j] + 1, distance[i][j - 1] + 1, distance[i - 1][j - 1]+ ((str1.charAt(i - 1) == str2.charAt(j - 1)) ? 0 : 1)); return new IntWritable(distance[str1.length()][str2.length()]); }
52162ce4-e975-4649-92d5-15b71bc300a1
public IntWritable evaluate(Text col1, Text col2) { if (col1 == null || col2 == null) { return null; } int insertCost = 1; int deleteCost = 1; int swapCost = 1; int replaceCost = 1; String source = col1.toString(); String target = col2.toString(); if (source.length() == 0) { return new IntWritable(target.length() * insertCost); } if (target.length() == 0) { return new IntWritable(source.length() * deleteCost); } int[][] table = new int[source.length()][target.length()]; Map<Character, Integer> sourceIndexByCharacter = new HashMap<Character, Integer>(); if (source.charAt(0) != target.charAt(0)) { table[0][0] = Math.min(replaceCost, deleteCost + insertCost); } sourceIndexByCharacter.put(source.charAt(0), 0); for (int i = 1; i < source.length(); i++) { int deleteDistance = table[i - 1][0] + deleteCost; int insertDistance = (i + 1) * deleteCost + insertCost; int matchDistance = i * deleteCost + (source.charAt(i) == target.charAt(0) ? 0 : replaceCost); table[i][0] = Math.min(Math.min(deleteDistance, insertDistance), matchDistance); } for (int j = 1; j < target.length(); j++) { int deleteDistance = table[0][j - 1] + insertCost; int insertDistance = (j + 1) * insertCost + deleteCost; int matchDistance = j * insertCost + (source.charAt(0) == target.charAt(j) ? 0 : replaceCost); table[0][j] = Math.min(Math.min(deleteDistance, insertDistance), matchDistance); } for (int i = 1; i < source.length(); i++) { int maxSourceLetterMatchIndex = source.charAt(i) == target .charAt(0) ? 0 : -1; for (int j = 1; j < target.length(); j++) { Integer candidateSwapIndex = sourceIndexByCharacter.get(target .charAt(j)); int jSwap = maxSourceLetterMatchIndex; int deleteDistance = table[i - 1][j] + deleteCost; int insertDistance = table[i][j - 1] + insertCost; int matchDistance = table[i - 1][j - 1]; if (source.charAt(i) != target.charAt(j)) { matchDistance += replaceCost; } else { maxSourceLetterMatchIndex = j; } int swapDistance; if (candidateSwapIndex != null && jSwap != -1) { int iSwap = candidateSwapIndex; int preSwapCost; if (iSwap == 0 && jSwap == 0) { preSwapCost = 0; } else { preSwapCost = table[Math.max(0, iSwap - 1)][Math.max(0, jSwap - 1)]; } swapDistance = preSwapCost + (i - iSwap - 1) * deleteCost + (j - jSwap - 1) * insertCost + swapCost; } else { swapDistance = Integer.MAX_VALUE; } table[i][j] = Math.min(Math.min(Math.min(deleteDistance, insertDistance), matchDistance), swapDistance); } sourceIndexByCharacter.put(source.charAt(i), i); } return new IntWritable(table[source.length() - 1][target.length() - 1]); }
997b96af-a8d3-4595-854d-36dacdfc50ee
@Override public String getDisplayString(String[] arg0) { return "arrayContainsExample()"; // this should probably be better }
413f8b3d-ea97-450a-92ea-ec2461995101
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 2) { throw new UDFArgumentLengthException("arrayContainsExample only takes 2 arguments: List<T>, T"); } // 1. Check we received the right object types. ObjectInspector a = arguments[0]; ObjectInspector b = arguments[1]; if (!(a instanceof ListObjectInspector) || !(b instanceof StringObjectInspector)) { throw new UDFArgumentException("first argument must be a list / array, second argument must be a string"); } this.listOI = (ListObjectInspector) a; this.elementOI = (StringObjectInspector) b; // 2. Check that the list contains strings if(!(listOI.getListElementObjectInspector() instanceof StringObjectInspector)) { throw new UDFArgumentException("first argument must be a list of strings"); } // the return type of our function is a boolean, so we provide the correct object inspector return PrimitiveObjectInspectorFactory.javaBooleanObjectInspector; }
6adc1cbc-265a-432a-8b73-641f70a1c40a
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { // get the list and string from the deferred objects using the object inspectors List<String> list = (List<String>) this.listOI.getList(arguments[0].get()); String arg = elementOI.getPrimitiveJavaObject(arguments[1].get()); // check for nulls if (list == null || arg == null) { return null; } // see if our list contains the value we need for(String s: list) { if (arg.equals(s)) return new Boolean(true); } return new Boolean(false); }
9732438c-8a03-4349-ac11-4c65ad25e7cb
public Text evaluate(Text input) { if(input == null) return null; return new Text("Hello " + input.toString()); }
1f6ed85d-0986-4ed3-9bc9-405e8cf5eb28
@Test public void testLUDF() { Levenshtein example = new Levenshtein(); Assert.assertEquals(2, example.evaluate(new Text("book"), new Text("back")).get()); Assert.assertEquals(3, example.evaluate(new Text("CA"), new Text("ABC")).get()); }
04b252eb-abe5-4c43-9060-6ad9178e9071
@Test public void testLUDFNullCheck() { Levenshtein example = new Levenshtein(); Assert.assertNull(example.evaluate(null, null)); Assert.assertNull(example.evaluate(null, new Text("word"))); Assert.assertNull(example.evaluate(new Text("apple"), null)); }
5c65d6f4-33df-4be3-8a47-d41b70fba746
@Test public void testDLUDF() { DamerauLevenshtein example = new DamerauLevenshtein(); Assert.assertEquals(2, example.evaluate(new Text("book"), new Text("back")).get()); Assert.assertEquals(2, example.evaluate(new Text("CA"), new Text("ABC")).get()); }
6421a934-71d5-4808-86a5-5516af3ef0cc
@Test public void testDLUDFNullCheck() { DamerauLevenshtein example = new DamerauLevenshtein(); Assert.assertNull(example.evaluate(null, null)); Assert.assertNull(example.evaluate(null, new Text("word"))); Assert.assertNull(example.evaluate(new Text("apple"), null)); }
1616d304-3b27-4a63-b263-366faae0d306
@Test public void testComplexUDFReturnsCorrectValues() throws HiveException { // set up the models we need ComplexUDFExample example = new ComplexUDFExample(); ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; ObjectInspector listOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); JavaBooleanObjectInspector resultInspector = (JavaBooleanObjectInspector) example.initialize(new ObjectInspector[]{listOI, stringOI}); // create the actual UDF arguments List<String> list = new ArrayList<String>(); list.add("a"); list.add("b"); list.add("c"); // test our results // the value exists Object result = example.evaluate(new DeferredObject[]{new DeferredJavaObject(list), new DeferredJavaObject("a")}); Assert.assertEquals(true, resultInspector.get(result)); // the value doesn't exist Object result2 = example.evaluate(new DeferredObject[]{new DeferredJavaObject(list), new DeferredJavaObject("d")}); Assert.assertEquals(false, resultInspector.get(result2)); // arguments are null Object result3 = example.evaluate(new DeferredObject[]{new DeferredJavaObject(null), new DeferredJavaObject(null)}); Assert.assertNull(result3); }
da2f7701-e4a4-41a2-a9c9-d5530afe48e7
@Test public void testUDF() { SimpleUDFExample example = new SimpleUDFExample(); Assert.assertEquals("Hello world", example.evaluate(new Text("world")).toString()); }
c23c692f-d942-4d6b-b976-3f221b69c40a
@Test public void testUDFNullCheck() { SimpleUDFExample example = new SimpleUDFExample(); Assert.assertNull(example.evaluate(null)); }
754bf330-013c-4362-9d29-45e6b3150908
public static List<String> getPlayers(File f) { try { List<String> temp = new ArrayList<>(); BufferedReader br = new BufferedReader(new FileReader(f)); String line; while ((line = br.readLine()) != null) temp.add(line); br.close(); return temp; } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. return new ArrayList<>(); } }
aae00d0b-99ae-4484-b320-c5564eda6d19
public void onEnable() { instance = this; owners = new ArrayList<>(); try { dir = new File(getDataFolder() + ""); if (!dir.exists()) dir.mkdir(); config = new File(getDataFolder() + "/config.yml"); if (!config.exists()) saveDefaultConfig(); data = new File(getDataFolder() + "/data.txt"); if (!data.exists()) data.createNewFile(); } catch (IOException ioe) { ioe.printStackTrace(); } new BukkitRunnable() { @Override public void run() { owners = DataReader.getPlayers(data); } }.runTaskAsynchronously(this); }
1a4b011d-16e6-4fe1-a5cf-2c3e6f668223
@Override public void run() { owners = DataReader.getPlayers(data); }
033ca32c-819e-4edd-8d86-8a37a24817bf
public void onDisable() { instance = null; }
c252eab9-f8cf-4e1f-9a35-3200af30409a
public static GolemGuard getInstance() { return instance; }
f673e4fb-178f-4b08-964f-c911d447678d
public boolean hasEconomyHook() { return this.getServer().getPluginManager().getPlugin("Vault") != null; }
8a0a9798-5eeb-43b3-963f-202558034851
public int getMieuw() { return mieuw; /*Comment added en meer ... en nog meer ... en weer meer*/ }
44f8f83b-750a-462f-9e35-d3df5c5d69a5
public static void main(String[] args) { bar fooBar = new bar(); System.out.println("Aantal:" + fooBar.getMieuw()); }
b5b07778-ce0b-4765-bed6-2219b1a64df7
protected int getKampioenschappen() { return kampioenschappen; }
f7a98ea8-0331-4338-bc58-2bf3d74590ab
public raceFiets(int aantalWielen, int aantalVersnellingen){ super(aantalWielen); this.aantalVersnellingen = aantalVersnellingen; }
25e148ac-5b69-41a4-9b51-831e303790b8
public int getAantalVersnellingen() { return aantalVersnellingen; }
afdc39e6-72de-49a6-9fae-d1191a650331
public void setAantalVersnellingen(int aantalVersnellingen) { this.aantalVersnellingen = aantalVersnellingen; }
372bfb4a-db94-4827-a268-73cfd350d701
public static void main(String[] args) { fiets mijnFiets = new raceFiets(3,7); System.out.println("" + mijnFiets.getFietstype() ); raceFiets mijnFiets2 = new raceFiets(3,7); System.out.println("" + mijnFiets2.getFietstype() ); }
b29c67db-e2d6-472b-881d-7fac15ee69f8
public fiets(int aantalWielen){ this.aantalWielen = aantalWielen; }
4e940dc9-684a-4e20-89b0-1ad1e8c2b193
public int getAantalWielen() { return aantalWielen; }
ef7273ab-55bb-4897-aa83-0ce459a8e842
public void setAantalWielen(int aantalWielen) { this.aantalWielen = aantalWielen; }
1b05f208-8639-47c8-87de-9d8a41c36f78
public String getFietstype(){ return fietsType; }
27463808-0662-47d7-b66c-a19cc766e988
public static void main(String[] args) { // TODO code application logic here System.out.println("Hoiii"); Employee Joram = new Employee("Joram","Hannema","Digitaal",1233445); Employee Jos = new Employee("Jos","Koster","Digitaal",12322115); Employee Philippe = new Employee("Philippe","Bressers","Digitaal",8267863); Employee Nabil = new Employee("Nabil","Zehabar","Business Intelligence",8200963); Manager Marian = new Manager("Marian","De Ruyter","Digitaal",4487755,"Audi A6"); Director Laurens = new Director("Laurens", "Lochtenberg","Digitaal",871430,"Audi A8",12_000_000); System.out.println("hallo " + Joram.getFirstName() + " " + Joram.getLastName()); System.out.println("Je zit op afdeling " + Joram.getDepartment() + " en hebt nummer " + Joram.getEmployeeNumber()); System.out.println("Je hebt geen leaseauto ... sorry :) "); System.out.println("hallo " + Marian.getFirstName() + " " + Marian.getLastName()); System.out.println("Je bent manager van de afdeling " + Marian.getDepartment() + " en hebt nummer " + Marian.getEmployeeNumber()); System.out.println("Jouw leaseauto is een " + Marian.getLeaseAuto()); Marian.addEmployee(Joram); Marian.addEmployee(Jos); Marian.addEmployee(Joram); Marian.addEmployee(Philippe); if(Joram instanceof Employee){ System.out.println("\n\t JA \n"); }else{ System.out.println("\n\t NEE \n"); } System.out.println("Overzicht van mensen met Marian als manager: "); for(Employee emp:Marian.getEmployeeArray()){ if( emp != null) System.out.println(emp.getLastName()); } System.out.println("Nu verwijderen we Philippe "); Marian.removeEmployee(Philippe); System.out.println("Opnieuw het overzicht van mensen met Marian als manager: "); for(Employee emp:Marian.getEmployeeArray()){ if( emp != null) System.out.println(emp.getLastName()); } if(Marian.findEmployee(Nabil) != -1){ System.out.println("Nabil gevonden"); }else{ System.out.println("Nabil niet gevonden"); } if(Marian.findEmployee(Joram) != -1){ System.out.println("Joram gevonden"); }else{ System.out.println("Joram niet gevonden"); } System.out.println("Details Joram: " + Joram.getDetails()); System.out.println("Details Marian: " + Marian.getDetails()); }
f6f441c9-e908-4c34-8cb1-66eaab4d139d
public Account(double balance){ this.balance = balance; }
0bbf862a-eec4-4d77-8ce9-45971089c75d
public double getBalance(){ return balance; }
f4b16de3-0caf-4c4b-8325-d587b7c4f2da
public void setBalance(double balance){ this.balance = balance; }
6369d5f7-c837-4dde-b322-401daf952b90
public Savings(double balance, double rate) { super(balance); this.interestRate = rate; }
38bce496-ec57-428d-a02f-17349d952719
public double getRate(){ return interestRate; }
2f782470-5bb5-4256-9a02-1104bd7b48ba
public void setRate(double interestRate){ this.interestRate = interestRate; }
c4e3e209-f60d-46a8-a409-170151d46f44
public static void main(String[] args) { String a = new String("Ajax Amsterdam"); String b = new String("abc"); if(a.equals(b)){ System.out.println(a + " equals Gelijk " + b); }else { System.out.println(a + " equals ONGelijk " + b); } if(a==b){ System.out.println(a + " ==Gelijk " + b); }else { System.out.println(a + " == ONGelijk " + b); } b = "Ajax Amsterdam"; if(a.equals(b)){ System.out.println(a + " equals Gelijk " + b); }else { System.out.println(a + " equals ONGelijk " + b); } if(a==b){ System.out.println(a + " == Gelijk " + b); }else { System.out.println(a + " == ONGelijk " + b); } }
999581e1-6761-4ee3-a0c0-a169fe4d2e1e
public Employee[] getEmployeeArray() { return employeeArray; }
ba4fe163-dc3b-4e3a-abd7-ad043497a797
@Override public String getDetails () { return super.getDetails() + ", Leaseauto: " + this.getLeaseAuto(); }
200f1436-ad52-4f01-82f7-5749451d3050
public void setEmployeeArray(Employee[] employeeArray) { this.employeeArray = employeeArray; }
7e08b211-32fa-4965-85f8-c24554b2bf97
public Manager(String firstName, String lastName, String department, int employeeNumber, String autoNaam){ super(firstName, lastName, department, employeeNumber); this.leaseAuto = autoNaam; }
779de1f0-97b3-4246-aa8f-b50bdc6ec275
public String getLeaseAuto() { return leaseAuto; }
8f51ec2a-cd43-4694-b9ef-72d9fb36cfff
public void setLeaseAuto(String leaseAuto) { this.leaseAuto = leaseAuto; }
72ce951c-568c-41a8-91f3-90bec6a678e5
public void removeEmployee(Employee emp){ if(employeeArray.length == 0){ return; } if(Arrays.asList(employeeArray).contains(emp)){ employeeArray[Arrays.asList(employeeArray).indexOf(emp)] = null; System.out.println(emp.getLastName() + " verwijderd ... "); } }
62472ea4-4040-4b35-bb37-e8788e418eb2
public void addEmployee(Employee emp){ if(!Arrays.asList(employeeArray).contains(emp)){ for(int i=0; i<employeeArray.length; i++){ if(employeeArray[i]==null){ employeeArray[i]=emp; break; } } System.out.println(emp.getLastName() + " Toegevoegd ... "); }else{ System.out.println(emp.getLastName() + " staat al in de lijst... "); } }
3715184b-8f9c-4290-b8e1-fc883e1d1093
public int findEmployee(Employee emp){ int result = -1; if(Arrays.asList(employeeArray).contains(emp)){ result = Arrays.asList(employeeArray).indexOf(emp); } return result; }
3966623c-245e-4dab-b494-0a0dd148a71b
public static float average(float[] values) { float result = 0; for(int i = 1; i < values.length; i++) result += values[i]; return (result/values.length); }
78fe1258-5058-42b0-8329-91434f94f277
public static void main(String[] args) { // TODO code application logic here System.out.println("Hoiii"); Employee Joram = new Employee("Joram","Hannema","Digitaal",1233445); Employee Jos = new Employee("Jos","Koster","Digitaal",12322115); Employee Philippe = new Employee("Philippe","Bressers","Digitaal",8267863); Manager Marian = new Manager("Marian","De Ruyter","Digitaal",4487755,"Audi A6"); Director Laurens = new Director("Laurens", "Lochtenberg","Digitaal",871430,"Audi A8",12_000_000); System.out.println("hallo " + Joram.getFirstName() + " " + Joram.getLastName()); System.out.println("Je zit op afdeling " + Joram.getDepartment() + " en hebt nummer " + Joram.getEmployeeNumber()); System.out.println("Je hebt geen leaseauto ... sorry :) "); System.out.println("hallo " + Marian.getFirstName() + " " + Marian.getLastName()); System.out.println("Je bent manager van de afdeling " + Marian.getDepartment() + " en hebt nummer " + Marian.getEmployeeNumber()); System.out.println("Jouw leaseauto is een " + Marian.getLeaseAuto()); Marian.addEmployee(Joram); Marian.addEmployee(Jos); Marian.addEmployee(Joram); Marian.addEmployee(Philippe); System.out.println("Overzicht van mensen met Marian als manager: "); for(Employee emp:Marian.getEmployeeArray()){ if( emp != null) System.out.println(emp.getLastName()); } System.out.println("Nu verwijderen we Philippe "); Marian.removeEmployee(Philippe); System.out.println("Opnieuw het overzicht van mensen met Marian als manager: "); for(Employee emp:Marian.getEmployeeArray()){ if( emp != null) System.out.println(emp.getLastName()); } /* System.out.println("hallo " + Laurens.getFirstName() + " " + Laurens.getLastName()); System.out.println("Je bent directeur van de afdeling " + Laurens.getDepartment() + " en hebt nummer " + Laurens.getEmployeeNumber()); System.out.println("Jouw leaseauto is een " + Laurens.getLeaseAuto()); System.out.println("Jouw budget is " + Laurens.getBudget()); */ }
e97ba493-5e02-4baf-93dd-bf7bce7f32f1
public Admin(String firstName, String lastName, String department, int employeeNumber, boolean fullTimer){ super(firstName, lastName, department, employeeNumber); this.fullTimer = fullTimer; }
5205a909-03f1-46e5-80f5-7c3b5c4882c7
public boolean isFullTimer() { return fullTimer; }