Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #7

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/DAOs/FacultyDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@
import Models.Faculty;
import javafx.scene.control.Alert;

/**
* Data Access Object (DAO) for interacting with the Faculty table in the
* database.
*
* @author Daniel Silva
*/
public class FacultyDAO {

/**
* Retrieves a faculty member by their ID from the database.
*
* @param id the ID of the faculty member
* @return the Faculty object representing the faculty member, or null if not
* found
*/
public static Faculty getFacultyById(String id) {
String user = System.getenv("USER");
String password = System.getenv("PASSWORD");
Expand Down Expand Up @@ -48,9 +61,13 @@ public static Faculty getFacultyById(String id) {
alert.showAndWait();
}
return null;

}

/**
* Retrieves all faculty members from the database.
*
* @return an ArrayList of Faculty objects representing all faculty members
*/
public static ArrayList<Faculty> getAllFaculties() {
String user = System.getenv("USER");
String password = System.getenv("PASSWORD");
Expand Down Expand Up @@ -89,6 +106,12 @@ public static ArrayList<Faculty> getAllFaculties() {
return null;
}

/**
* Inserts a new faculty member into the database.
*
* @param faculty the faculty member to be inserted
* @return true if the faculty member is successfully inserted, false otherwise
*/
public static boolean insertFaculty(Faculty faculty) {
String user = System.getenv("USER");
String password = System.getenv("PASSWORD");
Expand Down Expand Up @@ -122,6 +145,12 @@ public static boolean insertFaculty(Faculty faculty) {
}
}

/**
* Retrieves the full name of a faculty member with the given ID.
*
* @param id the ID of the faculty member
* @return the full name of the faculty member, or null if not found
*/
public static String getFacultyName(String id) {
String user = System.getenv("USER");
String password = System.getenv("PASSWORD");
Expand Down
23 changes: 13 additions & 10 deletions src/Utils/dataUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
import javafx.scene.control.Alert.AlertType;

public class DataUtilities {
/**
* Converts a grade string to a double value.
*
* @param grade the grade string to be converted
* @return the converted double value. Returns -1.0 if the grade string does not
* start with "A", "B", "C", "D", or "F".
*/
public static double convertGradeToDouble(String grade) {
if (grade.startsWith("A")) {
return 4.0;
Expand All @@ -26,6 +33,12 @@ public static double convertGradeToDouble(String grade) {
}
}

/**
* Retrieves the course name associated with the given CRN from the database.
*
* @param crn the CRN (Course Reference Number) of the course
* @return the course name if found, null otherwise
*/
public static String getCourseName(String crn) {
String user = System.getenv("USER");
String password = System.getenv("PASSWORD");
Expand All @@ -48,14 +61,4 @@ public static String getCourseName(String crn) {
}
return null;
}

public static String formatDateFromYYMMDDToMMDDYY(String date) {
String [] parts = date.split("-");
return parts[1] + "-" + parts[2] + "-" + parts[0];
}

public static String formatDateFromMMDDYYToYYMMDD(String date) {
String[] parts = date.split("-");
return parts[2] + "-" + parts[0] + "-" + parts[1];
}
}