Stream programming excercise: Buzzword Bingo
This exercise is unassessed.
Buzzword Bingo is a game in which two players compete to find text that is full of buzzwords. (Inspired by the inventor of the internet, not to mention Algoreithms, Al Gore.) You can choose your own list of buzzwords, or use the sample buzzword file provided. Note that a buzzword can contain spaces. Each line counts as one buzzword.
Each player supplies an URL of a web page they choose. The program then connects to the URL and scans the web page for the keywords from the buzzword file. Every time the program finds an occurrence of one of those buzzwords, a score is updated and at the end, the player with the highest score wins.
To make it even easier, here are some example steps which would be necessary for creating this program:
- Design your program to read the buzzword.txt file using I/O streams and store each term (either String or StringBuffer should do nicely for storage).
- Construct a regular expression for the buzzwords and compile it to a matcher.
- Open a connection to an URL, say for example, "http://www.cs.bham.ac.uk/~hxt/2011/19343/" and using Streams download the content of the web page and store it as well (again, String or StringBuffer should be sufficient). This is easily accomplished in Java. Please consult the Java API and here is an article detailing URL connections.
- Match repeatedly using find, and update the score accordingly.
- Repeat for the second player and display the score on screen. The player with the highest score wins.