Festive Coding Spirit (original) (raw)
The Twelve Days I Left It
I thought the java programmers among you would like these.I've not much use for them now i've handed them in. Should save me some money on cards anyway...
It's all about the frustrations faced by a UNIX administrator.
It should compile and run ok, depending on your version of java. This runs ok on 1.5 and 1.4.2. If it doesn't compile then the extra work is thrown in as an extra goodie. :D
Code for Version 1
`/**
- A simple Java program To: Print Out The Twelve Days I Left It
- Written by: Richard CT Shaw
- First Written: 31/10/2004 16:31
- Last updated: 31/10/2004 16:40
*/
import sheffield.*;
public class Assignment6_1 {
public static void main(String[] args) {
int dayNumber=1;
String dayName="First";
EasyWriter screen = new EasyWriter();
do {
switch (dayNumber){ // What day is it?
case 12: dayName = "Twelfth"; break;
case 11: dayName = "Eleventh"; break;
case 10: dayName = "Tenth"; break;
case 9: dayName = "Ninth"; break;
case 8: dayName = "Eighth"; break;
case 7: dayName = "Seventh"; break;
case 6: dayName = "Sixth"; break;
case 5: dayName = "Fifth"; break;
case 4: dayName = "Forth"; break;
case 3: dayName = "Third"; break;
case 2: dayName = "Second"; break;
case 1: dayName = "First"; break;
}
System.out.println(); //Print the first line of the verse
System.out.print("On the ");
System.out.print(dayName);
System.out.println(" day i left it, my UNIX gave to me:");
switch (dayNumber){ //Print the remaining lines of the verse; finds the current line prints that and then all preceding lines as well
case 12: System.out.println("Twelve boards a-blowing");
case 11: System.out.println("Eleven chips a-smocking;");
case 10: System.out.println("Ten ports a-jamming;");
case 9: System.out.println("Nine floppies frying;");
case 8: System.out.println("Eight gettys dying;");
case 7: System.out.println("Seven blown partitions;");
case 6: System.out.println("Six bad controllers;");
case 5: System.out.println("Five core dumps;");
case 4: System.out.println("Four Bad Blocks;");
case 3: System.out.println("Three heads crashed;");
case 2: System.out.println("Two faulty tapes;");
System.out.print("And ");
case 1: System.out.println("A Burnt out V.D.T."); break;
}
dayNumber++; // Increases day number
} while (dayNumber < 13);
}
}
`
Code for Version 2
`
/**
- A simple Java program To: Print Out The Twelve Days I Left It up to a specified day
- Written by: Richard CT Shaw
- First Written: 31/10/2004 16:31
- Last updated: 09/11/2004 18:00
*/
import sheffield.*;
public class Assignment6_2 {
public static void main(String[] args) {
EasyReader keyboard = new EasyReader();
int dayNumber = keyboard.readInt("Enter day to end on: ");
String dayName="First";
EasyWriter screen = new EasyWriter();
for (int i=1; i <(dayNumber+1); i++) { // Loop until day to end on is reached
switch (i){ // What day is it?
case 12: dayName = "Twelfth"; break;
case 11: dayName = "Eleventh"; break;
case 10: dayName = "Tenth"; break;
case 9: dayName = "Ninth"; break;
case 8: dayName = "Eighth"; break;
case 7: dayName = "Seventh"; break;
case 6: dayName = "Sixth"; break;
case 5: dayName = "Fifth"; break;
case 4: dayName = "Forth"; break;
case 3: dayName = "Third"; break;
case 2: dayName = "Second"; break;
case 1: dayName = "First"; break;
}
System.out.println(); //Print the first line of the verse
System.out.print("On the ");
System.out.print(dayName);
System.out.println(" day i left it, my UNIX gave to me:");
switch (i){ //Print the remaining lines of the verse; finds the current line prints that and then all preceding lines as well
case 12: System.out.println("Twelve boards a-blowing");
case 11: System.out.println("Eleven chips a-smocking;");
case 10: System.out.println("Ten ports a-jamming;");
case 9: System.out.println("Nine floppies frying;");
case 8: System.out.println("Eight gettys dying;");
case 7: System.out.println("Seven blown partitions;");
case 6: System.out.println("Six bad controllers;");
case 5: System.out.println("Five core dumps;");
case 4: System.out.println("Four Bad Blocks;");
case 3: System.out.println("Three heads crashed;");
case 2: System.out.println("Two faulty tapes;");
System.out.print("And ");
case 1: System.out.println("A Burnt out V.D.T."); break;
}
}
}
}
`
You also need the sheffield
package located at www.geocities.com/richardshawuk/bin/sheffield.zip in order for it to run properly. just unzip to a directory called sheffield in the same directory as the programs.
Any queries please comment.
X-Posted