Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package opdrachtB_2;
- import java.util.*;
- public class SillySentense
- {
- private HashMap<String, HashMap<Integer, String>> sentencesMap = new HashMap<String, HashMap<Integer, String>>();
- private Random random = new Random();;
- public SillySentense()
- {
- }
- public void fillSentence()
- {
- HashMap<Integer, String> map = new HashMap<Integer, String>();
- map.put(0, "#PERSON$ #DOES$ #SOMETHING$");
- map.put(1, "#PERSON$ thinks that I am #PROPERTY$");
- map.put(2, "I #DO$ #SOMETHING$");
- map.put(3, "you think that I am #PROPERTY$");
- sentencesMap.put("SENTENCE", map);
- }
- public void fillActivity()
- {
- HashMap<Integer, String> map = new HashMap<Integer, String>();
- map.put(0, "dancing");
- map.put(1, "eating");
- map.put(2, "sleeping");
- sentencesMap.put("ACTIVITY", map);
- }
- public void fillObject()
- {
- HashMap<Integer, String> map = new HashMap<Integer, String>();
- map.put(0, "#PERSOM$");
- map.put(1, "my computer");
- map.put(2, "my friends");
- sentencesMap.put("OBJECT", map);
- }
- public void fillDo()
- {
- HashMap<Integer, String> map = new HashMap<Integer, String>();
- map.put(0, "hate");
- map.put(1, "am jealous of");
- map.put(2, "love");
- sentencesMap.put("DO", map);
- }
- public void fillDoes()
- {
- HashMap<Integer, String> map = new HashMap<Integer, String>();
- map.put(0, "hates");
- map.put(1, "loves");
- sentencesMap.put("DOES", map);
- }
- public void fillPerson()
- {
- HashMap<Integer, String> map = new HashMap<Integer, String>();
- map.put(0, "my sister");
- map.put(1, "my father");
- map.put(2, "my girlgriend");
- map.put(3, "the man next door");
- sentencesMap.put("PERSON", map);
- }
- public void fillProperty()
- {
- HashMap<Integer, String> map = new HashMap<Integer, String>();
- map.put(0, "creative");
- map.put(1, "intelligent");
- sentencesMap.put("PROPERTY", map);
- }
- public void fillSomething()
- {
- HashMap<Integer, String> map = new HashMap<Integer, String>();
- map.put(0, "#ACTIVITY$");
- map.put(1, "#ACTIVITY$ with #PERSON$");
- map.put(2, "#OBJECT$");
- sentencesMap.put("SOMETHING", map);
- }
- public void fillItAll()
- {
- fillSentence();
- fillActivity();
- fillDo();
- fillDoes();
- fillObject();
- fillPerson();
- fillProperty();
- fillSomething();
- }
- @SuppressWarnings("rawtypes")
- public void print(int number)
- {
- for (int bla = 0; bla < number; bla++)
- {
- Map m = sentencesMap.get("SENTENCE");
- // m.toString();
- int r = random.nextInt(3);
- // System.out.println(r);
- String sentence = (String) m.get(r);
- String[] sentences = sentence.split(" ");
- String zin = "";
- for (int i = 0; i < sentences.length; i++)
- {
- String woord = sentences[i];
- // System.out.println(woord);
- if (woord.startsWith("#") && woord.endsWith("$")) // het is eenv ariable
- {
- woord = woord.substring(1, woord.length() - 1);// # en $ weghalen
- // System.out.println(woord);
- Map activity = sentencesMap.get(woord);
- int r2 = random.nextInt(activity.size() - 1);
- woord = (String) activity.get(r2);
- if (woord.startsWith("#") && woord.endsWith("$"))
- {
- // System.out.println(woord);
- woord = woord.substring(1, woord.length() - 1);// # en $ weghalen
- Map activity2 = sentencesMap.get(woord);
- int r3 = random.nextInt(activity2.size() - 1);
- woord = (String) activity2.get(r3);
- }
- // System.out.println("2" + woord);
- }
- zin = zin + " " + woord;
- }
- System.out.println(zin.trim());
- // for (int i = 0; i < m.size(); i++)
- // {
- //
- // }
- }
- }
- public void z(String s)
- {
- System.out.println(s);
- }
- @SuppressWarnings("rawtypes")
- public void printALL()
- {
- for (String key : sentencesMap.keySet())
- {
- Map m = sentencesMap.get(key);
- String bla = (String) key;
- for (int i = 0; i < m.size(); i++)
- {
- String woord = (String) m.get(i);
- System.out.println(bla + " : " + woord);
- }
- }
- }
- public void random()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment