MAINT: Apply pre-commit

Remove byte-order-marker pre-commit check as there would be
many adjustments necessary
This commit is contained in:
Martin Thoma
2022-03-05 09:29:23 +01:00
parent f5e33ae38f
commit e64fb6795c
536 changed files with 6267 additions and 5556 deletions

View File

@@ -6,64 +6,64 @@
* <p>
* Note: The idea was to create a version of the 1970's BASIC game in Java, without introducing
* new features - no additional text, error checking, etc has been added.
*
*
* Converted from BASIC to Java by Darren Cardenas.
*/
public class Calendar {
public class Calendar {
private static final int NUM_WEEK_ROWS = 6;
private static final int NUM_DAYS_PER_WEEK = 7;
private static final int NUM_MONTHS_PER_YEAR = 12;
private static final int[] daysPerMonth = { 0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31 };
private static final int NUM_MONTHS_PER_YEAR = 12;
private static final int[] daysPerMonth = { 0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31 };
public void play() {
showIntro();
startGame();
} // End of method play
} // End of method play
private static void showIntro() {
System.out.println(" ".repeat(31) + "CALENDAR");
System.out.println(" ".repeat(14) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
System.out.println("\n\n");
} // End of method showIntro
private void startGame() {
} // End of method showIntro
private void startGame() {
int dayOfMonth = 0;
int dayOfWeek = 0;
int dayOfYear = 0;
int daysTotal = 0;
int daysTotal = 0;
int index = 0;
int month = 0;
int row = 0;
int row = 0;
String lineContent = "";
for (index = 1; index <= 6; index++) {
System.out.println("");
for (index = 1; index <= 6; index++) {
System.out.println("");
}
daysTotal = -1;
dayOfYear = 0;
System.out.println("");
// Begin loop through all months
for (month = 1; month <= NUM_MONTHS_PER_YEAR; month++) {
System.out.println("");
dayOfYear = dayOfYear + daysPerMonth[month - 1];
lineContent = String.format("** %-3d" + "*".repeat(18), dayOfYear);
switch (month) {
switch (month) {
case 1:
lineContent += " JANUARY ";
break;
@@ -75,14 +75,14 @@ public class Calendar {
break;
case 4:
lineContent += " APRIL ";
break;
case 5:
break;
case 5:
lineContent += " MAY ";
break;
case 6:
break;
case 6:
lineContent += " JUNE ";
break;
case 7:
break;
case 7:
lineContent += " JULY ";
break;
case 8:
@@ -103,73 +103,73 @@ public class Calendar {
default:
break;
}
lineContent += "*".repeat(18) + " " + (365 - dayOfYear) + "**";
System.out.println(lineContent);
System.out.println("");
System.out.print(" S M T W");
System.out.println(" T F S");
System.out.println("");
System.out.println("*".repeat(59));
// Begin loop through each week row
for (row = 1; row <= NUM_WEEK_ROWS; row++) {
System.out.println("");
lineContent = " ";
// Begin loop through days of the week
for (dayOfWeek = 1; dayOfWeek <= NUM_DAYS_PER_WEEK; dayOfWeek++) {
daysTotal++;
dayOfMonth = daysTotal - dayOfYear;
if (dayOfMonth > daysPerMonth[month]) {
row = 6;
break;
break;
}
if (dayOfMonth > 0) {
if (dayOfMonth > 0) {
lineContent += dayOfMonth;
}
while (lineContent.length() < (4 + 8 * dayOfWeek)) {
lineContent += " ";
}
while (lineContent.length() < (4 + 8 * dayOfWeek)) {
lineContent += " ";
}
} // End loop through days of the week
if (dayOfMonth == daysPerMonth[month]) {
if (dayOfMonth == daysPerMonth[month]) {
row = 6;
daysTotal += dayOfWeek;
System.out.println(lineContent);
break;
}
System.out.println(lineContent);
} // End loop through each week row
daysTotal -= dayOfWeek;
daysTotal -= dayOfWeek;
} // End loop through all months
for (index = 1; index <= 6; index++) {
System.out.println("");
}
} // End of method startGame
for (index = 1; index <= 6; index++) {
System.out.println("");
}
} // End of method startGame
public static void main(String[] args) {
Calendar game = new Calendar();
game.play();
} // End of method main
} // End of class Calendar