My First Full-Fledged Project
This project helps people find overlapping free time in their schedules.
๐ How It Works:
- Enter your availability for a given day (e.g.,
4-6pm
and8-10pm
). - Enter a second person’s availability (e.g.,
5-9pm
). - The program prints a time spreadsheet and calculates when everyone is available.
- Works for up to four people at once.
๐ง Workings & Caveats:
- Utilized a 2-D Array to process user-provided schedules.
- Handling AM/PM time conversions (especially 10, 11, and 12) was challenging.
- Coded entirely inside a JVM.
๐ฝ Demo Video:
Unfortunately, the source code was lost due to it being stored on my school’s virtual machine.
However, a sample run of the program was recorded:
๐ Watch on YouTube
Recreation:
Here’s a recreation by ChatGPT (which negates the advanced user experience that I had crafted):
import java.util.*;
public class FreeTimeCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
boolean[] timeSlots = new boolean[24]; // each hour of the day
Arrays.fill(timeSlots, true); // Start with all available
for (int person = 1; person <= 4; person++) {
System.out.println("Enter availability for Person " + person + " (e.g., 4-6,8-10 or 'x' to skip): ");
String input = scanner.nextLine();
if (input.equalsIgnoreCase("x")) break;
boolean[] personSlots = new boolean[24];
Arrays.fill(personSlots, false);
String[] ranges = input.split(",");
for (String range : ranges) {
String[] hours = range.split("-");
int start = Integer.parseInt(hours[0].trim());
int end = Integer.parseInt(hours[1].trim());
for (int i = start; i < end; i++) {
personSlots[i] = true;
}
}
for (int i = 0; i < 24; i++) {
timeSlots[i] = timeSlots[i] && personSlots[i];
}
}
System.out.println("\nShared Free Time:");
boolean found = false;
for (int i = 0; i < 24; i++) {
if (timeSlots[i]) {
System.out.print(i + ":00 ");
found = true;
}
}
if (!found) {
System.out.println("No common availability.");
}
}
}