Skip to content

Commit

Permalink
Merge pull request #7 from danielsilva010:master
Browse files Browse the repository at this point in the history
merged the changes
  • Loading branch information
danielsilva010 authored Apr 16, 2024
2 parents 7ba0852 + 135eda2 commit e792d58
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
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];
}
}

0 comments on commit e792d58

Please sign in to comment.