id
stringlengths
36
36
text
stringlengths
1
1.25M
aaaa933c-a152-4010-8015-54e5cd0bfe90
public static void printGame(GameController game) { i++; System.out.printf("Runde %d %n", i); System.out.println(); System.out.println(game.s1); System.out.printf("Anzahl %d %n", game.s1.getAnzahl()); System.out.println(); for (int x = 0; x < game.s1.getAnzahl(); x++) { System.out.println(game.s1.team[...
7b397b61-f629-4cee-850d-47b707a496c3
public Ork() { super("Ork", "Sind sehr stark", 100, 30, 33, 1, 4); }
11f604ec-069f-4eef-b72d-fe4ef4756698
@Override public String toString() { return super.toString(); }
1b076608-d6f3-4ac8-a5f1-a55d9ade071e
@Override public double attack(Kaempfer r) { return super.attack(r); }
83442a5b-8aa2-4866-8e55-123429902f6b
@Override public double beschraenkeSchaden(double schaden) { return super.beschraenkeSchaden(schaden); }
0fe1a837-f5d5-4064-bbe8-8fdf347e9e8b
@Override public boolean isLebendig() { return super.isLebendig(); }
1439ee89-544b-431f-a2c4-5b8fd67350f8
@Override public String getElement() { // TODO Auto-generated method stub return ""; }
c456069f-1c4f-4886-a515-fb24060a5b0d
public Nachtelf() { super("Nachtelf", "Sind sehr intelligent", 120, 20, 15, 3, 2.9); }
ebeb8efd-0404-4dc6-830e-49360ff557a9
@Override public String toString() { return super.toString(); }
b1208ddc-0c4b-4aaa-b770-d3eca0d361cc
@Override public double attack(Kaempfer r) { return super.attack(r); }
287e77d1-bb29-46df-b77a-b1e404fe8a62
@Override public double beschraenkeSchaden(double schaden) { return super.beschraenkeSchaden(schaden); }
4fcc342d-7abc-4c44-ab61-51ea6ff7bd63
@Override public boolean isLebendig() { return super.isLebendig(); }
09581eff-62fa-4043-a1af-d8df42e56616
@Override public String getElement() { // TODO Auto-generated method stub return ""; }
59bc2017-122f-41f0-89ee-e2e38b7f5544
private Singleton() { }
3f2ba0dd-e7c4-4c86-8883-301230879afb
public static Singleton getInstance() { if (Singleton.instance == null) { Singleton.instance = new Singleton(); } return Singleton.instance; }
b3419e59-ff39-491c-bc58-f75c57a0d5e5
public Wesen(String rasse, String eigenschaft, double lebenspunkte, double ruestung, double schaden, double geschwindigkeit, double spezialAttribut) { this.rasse = rasse; this.eigenschaft = eigenschaft; this.lebenspunkte = lebenspunkte; this.ruestung = ruestung; this.schaden = schaden; this.geschwindi...
6374a381-6e37-4d42-a450-82fb1e6bd606
public String toString() { return "Rasse: " + rasse + ", Lebenspunkte: " + lebenspunkte; }
095307aa-61ee-4225-a568-d52c3b58622b
public double getHP() { return this.lebenspunkte; }
b3845e70-672b-4b18-a742-b5134c20be3d
@Override public double attack(Kaempfer r) { double damage = geschwindigkeit * schaden * spezialAttribut; r.erhalteSchaden(damage); return damage; }
8c5add4f-0269-4736-a405-592bbcd50ba4
@Override public double beschraenkeSchaden(double schaden) { return schaden; }
dc443036-ee2c-47ac-bd4b-78d9438a4952
@Override public double erhalteSchaden(double schaden) { if (schaden != 0) { this.lebenspunkte = this.lebenspunkte - (schaden - (this.ruestung * schaden / 100)); } return this.lebenspunkte; }
4aaa7d5e-13d0-4bed-9f10-5dc0c4f030e8
@Override public boolean isLebendig() { if (this.lebenspunkte <= 0) { return false; } else { return true; } }
f0002f2f-70f8-4006-8420-11b70e938911
@Override public boolean equals(Object obj) { if (obj == null || this.getClass() != obj.getClass()) { return false; } if (this == obj) { return true; } if (obj.getClass() == this.getClass()) { Wesen w = (Wesen) obj;// typecast Object zu // Festkommazahl if (this.lebenspunkte == w.lebensp...
0fa152fd-7f21-43d9-bfe9-43194c9a4196
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (int) (geschwindigkeit); result = prime * result + (int) (spezialAttribut); return result; }
02bacf98-fbe7-439c-b0a6-dbdf2994da27
private static void swap(Object[] array, int i, int j) { Object tmp = array[i]; array[i] = array[j]; array[j] = tmp; }
0a29c8f3-5439-4c95-9946-2af4a7a9988f
private static <E> int partition(E[] array, int begin, int end, Comparator<? super E> cmp) { int index = begin + RND.nextInt(end - begin + 1); E pivot = array[index]; swap(array, index, end); for (int i = index = begin; i < end; ++ i) { if (cmp.compare(array[i], pivot...
595212f3-4d5c-431d-a04c-710b9fae6cc9
private static <E> void qsort(E[] array, int begin, int end, Comparator<? super E> cmp) { if (end > begin) { int index = partition(array, begin, end, cmp); qsort(array, begin, index - 1, cmp); qsort(array, index + 1, end, cmp); } }
ab2459e5-d178-48b7-a3f2-da1ee8db640d
public static <E> void sort(E[] array, Comparator<? super E> cmp) { qsort(array, 0, array.length - 1, cmp); }
469e0b81-d994-4971-91bb-53a4afeb864e
@Override public LinkedList<Integer> sort(LinkedList<Integer> toSort) { LinkedList<Integer> sorted = new LinkedList<Integer>(); if (!toSort.isEmpty()) { sorted.addFirst(toSort.getFirst()); toSort.removeFirst(); } if (!toSort.isEmpty()) { for (Integer toInsert : toSort) { int index = 0; for (In...
49c37aef-f8e3-4fb9-b56e-82012ac6c964
public static void main(String[] args) { LinkedList<Integer> toSort = new LinkedList<Integer>(); LinkedList<Integer> sorted = new LinkedList<Integer>(); Integer[] intToSort = {7, 3, 2, 1, 4, 5, 9, 0, 8, 6}; toSort.addAll(Arrays.asList(intToSort)); InsertionSort is = new InsertionSort(); sorted = is.sort(toS...
cd22a515-a286-4fac-bd55-80ff3aeb69ec
public <E> void sort(E[] array, Comparator<? super E> cmp);
d9d0dae2-c9a0-4978-966e-71fca57e2e30
public LinkedList<Integer> sort(LinkedList<Integer> toSort);
79ea55e6-4fbb-45e3-86b9-1493414baf31
public int next(int row, int column, int degree) { int pathCount = 0; while (column <= degree && row <= degree) { if (column == degree && row == degree) { return 1; } pathCount += next(row + 1, column, degree); pathCount += next(row, column + 1, degree); break; } if (column > degree || row >...
b56fe0cf-97fc-486b-ad3c-e8a5a2adbe39
public static void main(String[] args) { GridPath gp = new GridPath(); System.out.print(gp.next(0, 0, 2)); }
6c5093b8-0934-4106-9a01-f7020bbaf4f0
public Shuffler(Random randomNumberGenerator) { this.randomNumberGenerator = randomNumberGenerator; }
2049d574-f510-4cce-9ee3-7b35ce71fba7
public Shuffler() { this(new Random()); }
90c8563e-6526-44af-9d12-4b79e1a6a6a5
public <T> void shuffle(List<T> objectsToShuffle) { Assert.isNotEmpty(objectsToShuffle, "shuffle(...):objectsToShuffle must not be empty!"); // start at back and work forward for (int i = objectsToShuffle.size() - 1; i > 1; i--) { // generate a random index from our current to the ...
a4d4dce9-6ca3-40ba-8f3e-af456bb53d0c
private Assert() { }
e20ec303-3865-42fb-918c-b8782141f1d4
public static void isNotEmpty(Collection<?> collection, String message) throws IllegalArgumentException { if (isEmpty(collection)) { throw new IllegalArgumentException(message); } }
1cda4beb-a049-43ab-a174-c12a57d8a5cd
private static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); }
58f9872e-612e-410a-9b6c-29f1293b3652
public List<Card> generateCards();
106a4acf-141b-4d8f-90d5-f1364da25359
public Deck(List<Card> cardList) { cards.addAll(cardList); }
ab0b52cc-aab0-4c2d-aa22-9745023a21ad
public Deck() { this(new Stack<Card>()); }
ea56b985-e74e-4e52-ba09-498df72c303f
public void shuffle() { Shuffler shuffler = new Shuffler(); shuffler.shuffle(cards); }
bdb34002-7606-4cba-928b-aced7bf21d27
public Card dealOneCard() { Card result = null; if (!cards.isEmpty()) { result = cards.remove(0); } return result; }
19ec3937-a964-4345-8dbc-667925e579aa
public int getSize() { return cards.size(); }
5bfa4e16-039c-4ef9-a885-454606c713b2
public String getDisplayString();
47cac461-8139-433a-834c-455f16991f7c
private FaceValue(int numberValue) { this.numberValue = numberValue; }
a87d2fc3-bf35-44e7-9a1a-0f432ae93574
public int getNumberValue() { return numberValue; }
e01459df-b1da-4d3a-afd1-ffeff69c6271
public PlayingCard(FaceValue faceValue, Suit suit) { this.suit = suit; this.faceValue = faceValue; }
a6149a54-2b8f-43df-bfa2-fd1980acd342
public Suit getSuit() { return suit; }
c52fe2b0-fdd1-4a63-8e96-3a9e8ea485aa
public FaceValue getFaceValue() { return faceValue; }
953ef2c7-a176-45a1-96f0-49ae6b27a0e9
public String getDisplayString() { return faceValue + " " + suit; }
a50ff496-5c1f-44a5-adbb-e8bf7dc7650b
@Override public String toString() { return new ToStringBuilder(this). append("suit", suit). append("faceValue", faceValue). toString(); }
aa2eebb3-b88d-4765-aefc-32fd5c4812aa
@Override public List<Card> generateCards() { List<Card> cards = new ArrayList<Card>(); for (Suit suit : Suit.values()) { for (FaceValue value : FaceValue.values()) { cards.add(new PlayingCard(value, suit)); } } return cards; }
9dfefeae-00c2-4273-aa55-8d14b6d27e5c
@Before public void setUp() throws Exception { // Seed the random Number generator shuffler = new Shuffler(new Random(RANDOM_SEED)); /** * build our baseline shuffle (our shuffle should work just like the JDK one as they are based on the * same algorithm) */ ...
9021a0a2-39dc-472d-9614-932e936bef0b
@Test public void shuffleTest() throws Exception { // Our list to shuffle List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9); shuffler.shuffle(numbers); for (int i = 0; i < numbers.size(); i++) { assertEquals(baselineShuffle.get(i), numbers.get(i)); ...
7b276e6c-8474-48c8-88ab-35a95314b27f
@Before public void setUp() throws Exception { PlayingCardFactory playingCardFactory = new PlayingCardFactory(); cardsInOriginalOrder = playingCardFactory.generateCards(); deck = new Deck(cardsInOriginalOrder); }
75f562fb-bd7c-4593-8b3c-41bb27301572
@Test public void testShuffle() throws Exception { boolean foundCardOutOfOrder = false; // shuffle the deck deck.shuffle(); for (Card card : cardsInOriginalOrder) { Card randomCard = deck.dealOneCard(); if (!card.equals(randomCard)) { foundC...
acfa80c7-9b8d-467a-8bb3-0dadeaad97c2
@Test public void testDealOneCard() throws Exception { // we got a card back! assertNotNull(deck.dealOneCard()); // Make a deck with no cards, we should not get a card back (or an NPE and the like) Deck emptyDeck = new Deck(); assertNull(emptyDeck.dealOneCard()); }
0b95302e-2422-441d-be54-0b5d2c609db5
@Test public void testCardsInRandomOrder() throws Exception { deck.shuffle(); int startingDeckSize = deck.getSize(); // these should all be cards for (int i = 0; i < startingDeckSize; i++) { Card temp = deck.dealOneCard(); assertNotNull(temp); } ...
28280518-b270-4b49-aa98-80e2be50bc2d
public Instance(String target, String[] senseids, String[] collocation){ this.target = target; this.senseids = senseids; this.collocation = collocation; this.lexelt = ""; this.instance_id = ""; }
9fc7a5fa-c2a9-4d84-a09c-d9a4e7ec13fd
public Instance(String target, String[] senseids, String[] collocation, String lexelt, String instance_id){ this.target = target; this.senseids = senseids; this.collocation = collocation; this.lexelt = lexelt; this.instance_id = instance_id; }
7699fafa-8e79-4f8c-9eba-70ceeb6b64f5
public Instance(String target, String[] senseids, String[] collocation, String lexelt, String instance_id, ArrayList<String> word_set){ this.target = target; this.senseids = senseids; this.collocation = collocation; this.lexelt = lexelt; this.instance_id = instance_id; this.word_set = word...
9b979619-ff2f-478d-9c19-672cfda4769a
public String headword(){ return lexelt.substring(0, lexelt.length()-2); }
661dc5d8-e53f-4115-8cc6-099267020b83
public NaiveBayes(ArrayList<Instance> instances) { countForFeatureForSense = new HashMap<Feature, HashMap<String, Integer>>(); countForSense = new HashMap<String, Integer>(); countForHeadWord = new HashMap<String, Integer>(); headwordSenseMap = new HashMap<String, ArrayList<...
e7cd4364-a200-4223-80d9-251ec03f3975
public void train() { for (Instance instance : instances) { // Update countForFeatureForSense if (USE_COLLOCATION) { for (int i = 0; i < instance.collocation.length; i++) { if (!instance.collocation[i].equals("")) { Feature ...
8ea2e7df-17bc-4337-88b0-3ca41d09f1a8
private void formulateProbabilites() { for (Feature feature : countForFeatureForSense.keySet()) { HashMap<String, Integer> senseMap = countForFeatureForSense.get(feature); for (String sense : senseMap.keySet()) { int count = senseMap.get(sense); if (!p...
86f741c0-ac65-4445-859b-25d86d6dd75d
public Double probability(Feature feature, String sense) { if (probFeatureGivenSense.containsKey(feature)) { if (probFeatureGivenSense.get(feature).containsKey(sense)) { return probFeatureGivenSense.get(feature).get(sense); } else { return defaultProbG...
d1cfba8f-166a-443b-b82b-29b5a6e273e3
public Double probability(String sense) { return probSense.get(sense); }
76dfc314-1fa1-43fb-a1fb-37f38b5a6e4e
public boolean senseOccurredInTraining(String headword, String sense) { return headwordSenseMap.containsKey(headword) && headwordSenseMap.get(headword).contains(sense); }
4454f31d-3df8-4178-821c-02d834c55211
public NaiveBayesTester(ArrayList<Instance> instances, NaiveBayes trainer) { this.instances = instances; this.trainer = trainer; }
ea69059d-cc7f-4f4e-91e9-2ab94c7abd4e
public void test() { for (Instance instance : instances) { String senseAnswer = ""; Double bestProb = 0.0; for (String sense : trainer.headwordSenseMap.get(instance.headword())) { Double curProb = 1.0; curProb *= trainer.probab...
87d25613-73ac-44f3-9734-5d54edae049b
private static String[] strings(String... strings) { return strings; }
681b048f-5fee-4581-b8f0-7ac09a4e6e8a
public static void main(String[] args) { ArrayList<Instance> instances = new ArrayList<Instance>(); instances.add(new Instance("bass", strings("fish"), strings("freshwater", "sea", "are", "becoming"))); instances.add(new Instance("bass", strings("music"), strings("guitar", "and", "player", "...
bcee97b6-8ce0-484e-a3d0-2f295ccae11a
private static String[] strings(String... strings) { return strings; }
55a36a21-3220-41a0-a62a-f20281ffb474
public static void main(String[] args) { if (args.length < 2) { System.out.println("Need training and test file as arguments."); } String trainFile = args[0]; String testFile = args[1]; WSDParser trainParser = new WSDParser(trainFile); ArrayList<I...
1bbb0c19-b976-41e3-9429-80626a506a12
public static void main(String[] args){ WSDParser parser = new WSDParser(trainingFile); ArrayList<Instance> x = parser.parse(new String[]{"argument"}); Instance i = x.get(4); System.out.println("|" + i.collocation[0] + "|" + i.collocation[1] + "|" + i.target + "|" + i.collocation[2] + "|" + i.collocation[3...
ac9ff882-4fba-4a45-81d8-4df41a9cbd5c
public WSDParser(String filename){ //initializing the xml parser try{ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(filename); rootElement = doc.getDocumentElement(); } catch(Exception e){ e.printStackTrac...
bdc0a563-9f5e-42e2-9073-6f8097aa38c0
public ArrayList<Instance> parse(String target){ //here we assume that we are parsing only nouns //and that there is only 1 lexelt per target NodeList lexelts = rootElement.getElementsByTagName("lexelt"); for(int i = 0; i<lexelts.getLength(); i++){ Element lexelt = (Element) lexelts.item(i); if(lexelt.get...
fa0e6b5b-325f-47c2-b198-09f2e6e1def0
public ArrayList<Instance> parse(String[] targets){ for(int i=0; i<targets.length; i++){ parse(targets[i]); } return examples; }
90973420-5920-40ad-b80f-1e801e8d1211
private void parseLexelt(String target, Element lexelt){ ArrayList<Instance> targetExamples = new ArrayList<Instance>(); NodeList instances = lexelt.getElementsByTagName("instance"); for(int i=0; i<instances.getLength(); i++){ Element instance = (Element) instances.item(i); targetExamples.add(parseInstance(...
94f8f4a9-9bc3-4c5e-9fb2-4a96bc9fbe55
private Instance parseInstance(String target, Element instance){ Element context = (Element) instance.getElementsByTagName("context").item(0); String id = instance.getAttribute("id"); return new Instance( parseTarget(context), parseAnswers(instance), parseCollocation(context), target+".n", i...
1d3c02e2-7685-4718-9ad1-b22bcb26931a
private String parseTarget(Element context){ Element head = (Element) context.getChildNodes().item(1); return head.getTextContent().toLowerCase(); }
a517e76c-e029-405d-a1f1-3d854522f6c8
private String[] parseAnswers(Element instance){ NodeList answers = instance.getElementsByTagName("answer"); String[] senseids = new String[answers.getLength()]; for(int i=0; i<senseids.length; i++){ Element answer = (Element) answers.item(i); senseids[i] = answer.getAttribute("senseid"); } return sense...
0828bd6e-d1bf-4cc5-91b2-b4d2284deb20
private ArrayList<String> parseCooccurrence(Element context){ ArrayList<String> inContext = new ArrayList<String>(); String[] pre = parseTextNode(context.getFirstChild()); String[] post = parseTextNode(context.getLastChild()); inContext.addAll(Arrays.asList(pre)); inContext.addAll(Arrays.asList(post)); ret...
ea3ed56d-0731-413a-b370-e084476122a7
private String[] parseCollocation(Element context){ String[] pre = parseTextNode(context.getFirstChild()); String[] post = parseTextNode(context.getLastChild()); String[] collocation = new String[]{ pre[pre.length-4], pre[pre.length-3], pre[pre.length-2], pre[pre.length-1], post[0], post[...
b91b7772-9225-403f-905d-116726bd024b
private String[] parseTextNode(Node node){ String text = node.getNodeValue(); text = text.replaceAll("\\s+\\p{Punct}+\\s", ""); text = text.trim().toLowerCase(); String[] textArray = text.split("\\s"); return textArray; }
9b69ac84-ab40-4154-8635-b41850122450
public Feature(String word) { this.word = word; this.offset = -1; }
490b7ed3-27c5-4605-a80e-7db998a0df15
public Feature(String word, Integer offset) { this.word = word; this.offset = offset; }
9a92e241-eda1-40e7-a84b-d0016404bb49
public boolean equals(Object f) { if (f instanceof Feature) { return (word.equals(((Feature)f).word) && offset.equals(((Feature)f).offset)); } return false; }
be02e976-d421-4a49-8119-2aafc8e29c5e
public int hashCode() { return word.hashCode() + offset.hashCode(); }
fc7303f2-45ea-48c6-92c6-322e7c505dcb
public String toString() { if (offset > 2) { return word; } return word + "_" + offset.toString(); }
f87d8f97-994a-406b-9b9b-5afc3b46ab83
public static void main(String[] args) { CacheFactory.ensureCluster(); NamedCache nc_act = CacheFactory.getCache("accounts"); System.out.println("==> Staring batch process!"); Map m = nc_act.invokeAll((Filter)null, new NullEP()); System.out.println("The size of result of invo...
e8d53bf0-d209-42d1-8f87-4f538dfc37e8
public static void main(String[] args) { System.out.println("==> Staring batch process!"); InvocationService ivSvc = (InvocationService)CacheFactory.getService("Invocation_Test_Svc"); Map map = ivSvc.query(new BatchTask(), null); System.out.println("The result of InvocationService is : \n\t"+map); ...
1de98254-12d5-4f14-b36f-d67e5dfa2dd4
public static void main(String[] args) { CacheFactory.ensureCluster(); NamedCache nc_act = CacheFactory.getCache("accounts"); String str_act_id, ops; int value=0; Scanner sc = new Scanner(System.in); System.out.print("Please input 'Account ID':"); str_act_id = sc.next(); System.out.print("Please...
0685f988-95de-40c2-9fcc-5b6879d1b70f
public static void main(String[] args) throws InterruptedException { Logger logger = LogManager.getLogger(ReadBalance.class.getName()); CacheFactory.ensureCluster(); NamedCache nc_bal = CacheFactory.getCache("balances"); String str_aid, str_bid; int i_times=0; Scanner sc = new Scanner(Sys...
9eecf682-77d9-4d28-988d-bafaf47e7329
public static void main(String[] args) { CacheFactory.ensureCluster(); int a, b; int b_per_a = 3; String str_act_id; String str_bal_id; NamedCache nc_act = CacheFactory.getCache("accounts"); NamedCache nc_bal = CacheFactory.getCache("balances"); System.out.println("== "+nc_act.getClass()...
2a2a5496-c17b-4aa3-ad37-bd7d4ba0023e
public static void main(String[] args) { CacheFactory.ensureCluster(); NamedCache nc_act = CacheFactory.getCache("accounts"); String ep_name; String str_act_id, str_bal_id=null; Scanner sc = new Scanner(System.in); System.out.print("Please input the name of EP to invoke(sleep/backingmap/add/r...
515b561d-751e-479e-a5b6-c23b9dbfe823
public AccountId() { super(); }