Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
*/
package com.mycompany.assign_final;
import java.util.List;
/**
*
@author atom
*/
public class Assign_final {
public static void main(String[] args) {
new EventSchedulerGUI();
}
}
Assign_final.java
Skip to main content
Google ClassroomClassroom
SCD-A (Fall 2024)A
O
T
S
O
S
O
S
F
S
O
A
E
Assignment-2
Assignment-2
farooq ahmed
•
Oct 10
40 points
Due Oct 21, 11:59 PM
Implement using Java Swing
Assignment-2.pdf
PDF
Class comments
Your work
Turned in
Assign_final.java
Java
EventSchedulerGUI.java
Java
Room.java
Java
Scheduler.java
Java
Seminar.java
Java
Slot.java
Java
Private comments
/*
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.assign_final;
Your EventSchedulerGUI Java Swing application is a solid foundation for an event scheduling system. It provides a user interface with three main tabs: Seminars, Scheduling, and Conflicts. Additionally, it includes functionality to upload seminar and scheduling files, display the corresponding data, and analyze conflicts.
However, to have a fully functional application, you'll need to implement the backend classes (Scheduler, Seminar, Room, Slot, etc.) that interact with this GUI. Below, I'll guide you through completing your application by providing sample implementations for these classes and ensuring they integrate seamlessly with your existing GUI.
1. Overview of the Current Implementation
Assign_final.java
This is the entry point of your application. It simply initializes and displays the EventSchedulerGUI.
java
package com.mycompany.assign_final;
public class Assign_final {
public static void main(String[] args) {
new EventSchedulerGUI();
}
}
EventSchedulerGUI.java
This class sets up the GUI using Java Swing. It includes:
Three Tabs:
Seminars: Displays seminar details.
Scheduling: Displays scheduling details.
Conflicts: Displays any scheduling conflicts detected.
Buttons:
Upload Seminar File: Allows users to upload a file containing seminar details.
Upload Scheduling File: Allows users to upload a file containing scheduling details.
Analyze: Processes the data to find conflicts.
Tables:
Seminar Table: Shows seminars with columns for Seminar name, Speaker, and Attendees.
Scheduling Table: Shows scheduling with columns for Seminar, Room, and Time Slot.
Conflict Table: Displays any conflicts found during analysis.
Missing Backend Classes
To make this GUI functional, you'll need to implement the following classes:
Scheduler: Handles the logic for loading seminars and scheduling data, and detecting conflicts.
Seminar: Represents a seminar with attributes like name, speaker, attendees, assigned room, and time slot.
Room: Represents a room with attributes like room number and capacity.
Slot: Represents a time slot with attributes like slot ID and time range.
2. Implementing Backend Classes
2.1. Seminar Class
java
package com.mycompany.assign_final;
import java.util.ArrayList;
import java.util.List;
public class Seminar {
private String name;
private String speaker;
private List<String> attendeeIds;
private Room room;
private Slot slot;
public Seminar(String name, String speaker, List<String> attendeeIds) {
this.name = name;
this.speaker = speaker;
this.attendeeIds = attendeeIds != null ? attendeeIds : new ArrayList<>();
}
// Getters and Setters
public String getName() {
return name;
}
public String getSpeaker() {
return speaker;
}
public List<String> getAttendeeIds() {
return attendeeIds;
}
public Room getRoom() {
return room;
}
public void setRoom(Room room) {
this.room = room;
}
public Slot getSlot() {
return slot;
}
public void setSlot(Slot slot) {
this.slot = slot;
}
}
2.2. Room Class
java
package com.mycompany.assign_final;
public class Room {
private String roomNumber;
private int capacity;
public Room(String roomNumber, int capacity) {
this.roomNumber = roomNumber;
this.capacity = capacity;
}
// Getters
public String getRoomNumber() {
return roomNumber;
}
public int getCapacity() {
return capacity;
}
}
2.3. Slot Class
java
package com.mycompany.assign_final;
public class Slot {
private String slotId;
private String timeRange;
public Slot(String slotId, String timeRange) {
this.slotId = slotId;
this.timeRange = timeRange;
}
// Getters
public String getSlotId() {
return slotId;
}
public String getTimeRange() {
return timeRange;
}
@Override
public String toString() {
return timeRange;
}
}
2.4. Scheduler Class
The Scheduler class is the core of your application. It manages seminars, rooms, slots, and handles the conflict analysis.
java
Explanation:
Initialization:
Pre-defines some rooms and time slots. You can modify these or load them from a configuration file as needed.
Loading Seminars:
Expects a CSV file where each line represents a seminar in the format: SeminarName,Speaker,Attendee1;Attendee2;Attendee3
Parses each line and creates Seminar objects.
Loading Scheduling:
Expects a CSV file where each line represents a scheduling assignment in the format: SeminarName,RoomNumber,SlotId
Assigns rooms and slots to seminars based on the data.
Conflict Analysis:
Checks if multiple seminars are scheduled in the same room and time slot.
You can extend this method to include more sophisticated conflict checks, such as attendee scheduling conflicts or room capacity issues.
2.5. Example Seminar and Scheduling Files
To test your application, you'll need example CSV files.
Note: Save these files in a directory accessible from your application. When uploading, navigate to their location to select them.
3. Enhancing the GUI
While your current GUI provides basic functionality, here are some enhancements you can consider:
3.1. Display Available Rooms and Slots
You can add additional tabs or sections to display available rooms and slots, helping administrators make informed scheduling decisions.
3.2. Add Functionality to Add/Edit Seminars and Schedules
Allow users to add, edit, or delete seminars and their scheduling directly from the GUI without needing to upload files each time.
3.3. Conflict Resolution
Provide options within the GUI to resolve identified conflicts, such as reassigning seminars to different rooms or slots.
3.4. Validation and Error Handling
Ensure that the uploaded files are correctly formatted and handle any inconsistencies or errors gracefully, providing user-friendly messages.
4. Complete Example
Here's how everything ties together with the implemented classes.
4.1. Complete EventSchedulerGUI.java
To ensure seamless integration, here's the complete EventSchedulerGUI.java with minor adjustments to handle room and slot data display.
java
Enhancements Made:
Menu Bar: Added a simple "Help" menu with an "About" dialog.
User Feedback: Added JOptionPane dialogs to inform users when files are successfully loaded or when conflicts are detected/nothing is found.
Centering Window: The GUI window is now centered on the screen.
Improved File Dialog Titles: Provides clearer instructions when selecting files.
5. Running the Application
Prepare CSV Files:
Create seminars.csv and scheduling.csv as per the formats provided earlier.
Example contents are given above.
Compile and Run:
Ensure all classes (Assign_final, EventSchedulerGUI, Scheduler, Seminar, Room, Slot) are in the com.mycompany.assign_final package.
Compile the project using your IDE or javac.
Run the Assign_final class to launch the GUI.
Using the Application:
Seminars Tab: Click "Upload Seminar File" and select your seminars.csv. The table will display the seminars.
Scheduling Tab: Click "Upload Scheduling File" and select your scheduling.csv. The table will display the scheduling assignments.
Conflicts Tab: Click "Analyze" to detect any conflicts based on the current scheduling. Results will appear in the table.
6. Further Improvements
To enhance your application further, consider implementing the following features:
6.1. Dynamic Room and Slot Management
Allow users to add, edit, or remove rooms and slots through the GUI rather than hardcoding them in the Scheduler class.
6.2. Attendee Scheduling Conflicts
Implement logic to check if an attendee is scheduled to attend multiple seminars at the same time.
6.3. Room Capacity Validation
Ensure that the number of attendees for a seminar does not exceed the room's capacity. Highlight or prevent such conflicts.
6.4. Exporting Results
Provide functionality to export the seminars, scheduling, and conflicts to CSV or PDF formats for reporting purposes.
6.5. Enhanced Conflict Analysis
Develop more sophisticated algorithms for conflict detection, such as:
Speaker Availability: Ensure a speaker isn't double-booked.
Slot Preferences: Allow seminars to have preferred or required time slots.
Room Features: Assign rooms based on specific seminar requirements (e.g., projectors, seating arrangements).
6.6. User Authentication
If multiple users will interact with the system, implement authentication to manage permissions and track changes.
6.7. Database Integration
For scalability and persistence, integrate a database (e.g., MySQL, PostgreSQL) instead of relying on CSV files. This allows for more efficient data management and querying.
7. Conclusion
You've made great progress in setting up an event scheduler using Java Swing. By implementing the backend classes and ensuring they interact properly with your GUI, your application can effectively manage seminars, scheduling, and conflict detection. Continue refining your application by adding features, enhancing the user experience, and ensuring robust error handling. Good luck with your assignment!
If you have any specific questions or need further assistance with particular aspects of your project, feel free to ask!