Programming 1 / 2008

Demo 8 / 3.11

Tasks

1.
Ville: Run Ville web application (look: https://trac.cc.jyu.fi/projects/ohj1/wiki/villeEn) and carry out task round: Arrays. Scale the amount of tasks done to the range [1,0] and round the point you get with precision of 0.2. (An example: if you did 120/195 tasks (=0.615) mark 0.6 as you final point. If 140/195 (=0.72) mark 0.8.)
2.
If, switch, table : Write 3 different functions season(int month) that returns the season of the month given as a parameter. One uses the if -clause, one uses the switch -clause and the third uses a table.
3.
Leap year: Write a boolean function leapYear(year) that returns true if the year is a leap year. Leap years are those years that are divisible by four except those that are divisible by 400 (e.g. 1900 not a leap year). Think up a good test program.
4-5.
Dividers: Look at the picture dividers.png. It describes the divisibility of numbers so that for every x (integer) has a circle if the number is divisible by the corresponding y (integer). If a number is a prime number (divisible only by 1 and itself) it has a green line drawn on it. Write a program that draws a similar picture. Get the newest Graphics.jar so you can use the Marker object that is faster than the Circle. Hint: First draw a similar picture by hand and think about what you are doing.
6.
Hangman: Alter the code of the Hangman2.java so that no actions will happen if a same letter is given again. To compile the program you need to have Hangman.java and DrawTimber.java. Add another modification to make the program not case-sensitive.
B1.
Familiarize yourself with the ComTest and learn how to use it. Write your own tests and run them with tasks 2 and 3.

GURU-tasks

G1-2.
Create a version of the hangman game in which you print the phases of the gallows as text on the command line. Try to make as modifiable version as possible.