Last active
August 29, 2015 14:01
-
-
Save dashorst/e5dd5e3102bad86190cb to your computer and use it in GitHub Desktop.
Code voor gebruik in cheesy-quotes Android project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Een quote van een persoon: bevat de tekst of uitspraak en een attribution | |
* van de persoon die de quote gezegd of geschreven heeft. | |
*/ | |
public class Quote { | |
private String text; | |
private String attribution; | |
public String getText() { | |
return text; | |
} | |
public void setText(String text) { | |
this.text = text; | |
} | |
public String getAttribution() { | |
return attribution; | |
} | |
public void setAttribution(String attribution) { | |
this.attribution = attribution; | |
} | |
public static Quote q(String text, String attribution) { | |
Quote q = new Quote(); | |
q.setAttribution(attribution); | |
q.setText(text); | |
return q; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Database van Quote objecten met diverse uitspraken over kaas. | |
* | |
* Je kan een random quote opvragen via {@link #get()}. | |
*/ | |
public class Quotes { | |
/** | |
* Geeft een random Quote terug. | |
*/ | |
public static Quote get() { | |
return quotes.get(random.nextInt(quotes.size())); | |
} | |
private static final List<Quote> quotes = new ArrayList<Quote>(); | |
private static Random random = new Random(); | |
// @formatter:off | |
static { | |
quotes.add(Quote.q("Poets have been mysteriously silent on the subject of cheese.", "G.K. Chesterton")); | |
quotes.add(Quote.q("How can you govern a country which has 246 varieties of cheese?","Charles de Gaulle")); | |
quotes.add(Quote.q("The early bird gets the worm, but the second mouse gets the cheese.","Willie Nelson")); | |
quotes.add(Quote.q("Give me a good sharp knife and a good sharp cheese and I’m a happy man.","George R.R. Martin")); | |
quotes.add(Quote.q("What happens to the hole when the cheese is gone?","Bertolt Brecht")); | |
quotes.add(Quote.q("You have to be a romantic to invest yourself, your money, and your time in cheese.","Anthony Bourdain")); | |
quotes.add(Quote.q("Life is great. Cheese makes it better.","Avery Aames")); | |
quotes.add(Quote.q("Age is something that doesn't matter, unless you are a cheese.","Luis Bunuel")); | |
} | |
// @formatter:on | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment