Project Phase 1
Overview
The first part of your project will start with a working implementation of the "99 bottles of beer" program in your language. You will then need to modify this program according to the specifications below. Which modifications you need to make depend on your programming language, and are listed on the page for that language. So you probably won't need to make every modification listed below.
Also, to be clear, you should just submit a simple program that does all the modifications at once. Everyone should submit a simgle program as described on your language's page. That one program should do all the modifications that I have listed.
A link to the 99 bottles of beer program that I think is "best" for your programming language is also available on each language's web page. Here are the links to those pages, for your convenience:
brainfuck, Piet, Dart, C Sharp, Rust, Elixir, Go, Prolog, Haskell, Red, Elm, Clojure, Nim, Ruby, Lua
Grading
Phase 1 counts as 20% of your total project grade. The goal is to "get your feet wet" with the basics of the language and the development environment (compiler, interpreter, IDE, whatever). With this goal in mind, I recommend taking the time to make sure you actually understand what you're doing. You might be able to get away with just some minor edits to the existing code, producing a working program without still having any comprehension of it. This will not prepare you well for Phase 2, which will be more difficult, and more independent.
To encourage you to take this advice seriously, coding style will count for 50% of your grade for this part of the project, and the actual correctness for the other 50%. This means that you need to do things like:
- Document carefully, explaining what's going on to someone (like your professor) that's not very familiar with your language. This means choosing really good, informative names for any variables, and including plenty of informative comments.
- Make sure your code is easily readable. Apply consistent indentation according to the standards of your language, and vertical whitespace throughout to separate different parts of the code.
- Use appropriate features of your language. If it's an object-oriented language, you probably want to make an object. If it's a functional language, I expect to see some recursion. In most cases (esoteric languages excluded), you will definitely want to define at least a few helper functions or methods. Even if it seems like overkill for this assignment, taking the time to "do it right" will benefit you for phase 2, and it will benefit your style grade for this part too!
The Modifications
Remember, which of these you need to do is specified on that language's page. They are referred to there by their letters here.
- Count up from 1 instead of down from 99. After this, your program should
output something like
1 bottle of beer on the wall, 1 bottle of beer. Take one down, pass it around, 2 bottles of beer on the wall. 2 bottles of beer on the wall, 2 bottles of beer. Take one down, pass it around, 3 bottles of beer on the wall. ... 99 bottles of beer on the wall, 99 bottles of beer. Take one down, pass it around, 100 bottles of beer on the wall.
- Of course that doesn't make much sense. So change the lyrics to look
like:
1 line of text on the screen, 1 line of text. Print it out, stand up and shout, 2 lines of text on the screen. 2 lines of text on the screen, 2 lines of text. Print it out, stand up and shout, 3 lines of text on the screen. ... 99 lines of text on the screen, 99 lines of text. Print it out, stand up and shout, 100 lines of text on the screen.
Actually, you can change the lyrics to whatever you like, as long as it follows this general pattern (should be counting up something in the lyrics from 1 to 100). Nothing you'd be embarrassed to sing though... - Count up to 500, but instead of incrementing by 1 every time, choose a random number between 1 and 10 and increment by that. Since it's random, I should get a different output every time I run your program.
- Display a prompt like "How many lines? " and read an integer from the terminal. Then stop the song when you hit that number (instead of 100 or 500).
- Like (D), but instead of reading the number of lines from the terminal, pop up a dialog box with the prompt and an input box for the number.
- Pause 1 second between printing out each stanza to the screen, for dramatic effect.
-
Print each number fully factored into its prime factors. For
instance, 1 should print as
()
- an empty pair of parentheses, 2 will print as(2)
, 24 as(2*2*2*3)
, etc. -
Open a file called "
out.txt
" in the current directory and output both to the screen and to that file. The lyrics in the file should be slightly different, like "lines of text in the file" or whatever you like (within reason). - Print to to the screen and write to out.txt concurrently, in separate processes or threads within your program. Have each thread announce when it finishes, by writing a message to stderr like "Screen finished" or "File finished". Note that you should not pause between writing lines to the file, even if you completed modification (F).
-
Change the lyrics by querying a web API.
You can use any web API as long as it's free and returns something different every time
using JSON.
Two APIs I just found: https://boredapi.com/api/activity and http://api.kanye.rest.
For example, if you use the "bored activity" API, your lyrics might change to something like1 bottle of beer on the wall, 1 bottle of beer. Make a simple musical instrument, 2 bottles of beer on the wall. (etc.)
Or using Kanye REST, maybe1 bottle of beer on the wall, 1 bottle of beer. Distraction is the enemy of vision, 2 bottles of beer on the wall. (etc.)
Again, the important thing is that you make an actual web API query in your program and parse the JSON that comes back, and the result should be different each time I run it.