Is it possible to add objects into an Arraylist through a for-loop?
I would like to shorten down the code! or do you have any other tips on how to create a word quiz with different classes and methods?
I have three classes, Main
that drives the game, Quiz
where the game is constructed, and a class with the Dictionary with all the words.
ArrayList<Sweng> Wordlist = new ArrayList<Sweng>();
Sweng s1 = new Sweng("bil", "car");
Sweng s2 = new Sweng("blå", "blue");
Sweng s3 = new Sweng("baka", "bake");
Sweng s4 = new Sweng("hoppa", "jump");
Sweng s5 = new Sweng("simma", "swim");
Sweng s6 = new Sweng("måne", "moon");
Sweng s7 = new Sweng("väg", "road");
Sweng s8 = new Sweng("snäll", "kind");
Sweng s9 = new Sweng("springa", "run");
Sweng s10 = new Sweng("hus", "house");
Wordlist.add(s1);
Wordlist.add(s2);
Wordlist.add(s3);
Wordlist.add(s4);
Wordlist.add(s5);
Wordlist.add(s6);
Wordlist.add(s7);
Wordlist.add(s8);
Wordlist.add(s9);
Wordlist.add(s10);