Commit 15369ed7 authored by NewbieOrange's avatar NewbieOrange
Browse files

Update DTOs and course service interface

parent e647ecf0
Loading
Loading
Loading
Loading
+39 −2
Original line number Diff line number Diff line
package cn.edu.sustech.cs307.dto;

import java.time.DayOfWeek;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;


public class CourseTable {
@@ -23,11 +24,47 @@ public class CourseTable {
         * The class location.
         */
        public String location;

        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            CourseTableEntry entry = (CourseTableEntry) o;
            return classBegin == entry.classBegin && classEnd == entry.classEnd && courseFullName
                    .equals(entry.courseFullName)
                    && instructor.equals(entry.instructor) && location.equals(entry.location);
        }

        @Override
        public int hashCode() {
            return Objects.hash(courseFullName, instructor, classBegin, classEnd, location);
        }
    }

    /**
     * Stores all courses(encapsulated by CourseTableEntry) according to DayOfWeek.
     * The key should always be from MONDAY to SUNDAY, if the student has no course for any of the days, put an empty list.
     */
    public Map<DayOfWeek, List<CourseTableEntry>> table;
    public Map<DayOfWeek, Set<CourseTableEntry>> table;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        CourseTable that = (CourseTable) o;
        return table.equals(that.table);
    }

    @Override
    public int hashCode() {
        return Objects.hash(table);
    }
}
+22 −0
Original line number Diff line number Diff line
package cn.edu.sustech.cs307.dto;

import java.sql.Date;
import java.util.Objects;

public class Student extends User {
    public Date enrolledDate;

    public Major major;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        Student student = (Student) o;
        return enrolledDate.equals(student.enrolledDate) && major.equals(student.major);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), enrolledDate, major);
    }
}
+19 −0
Original line number Diff line number Diff line
package cn.edu.sustech.cs307.dto;

import java.util.Objects;

public abstract class User {

    public int id;
@@ -10,4 +12,21 @@ public abstract class User {
     * if first name 'David Lee' and last name 'Roth' then full name is 'David Lee Roth'.
     */
    public String fullName;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        User user = (User) o;
        return id == user.id && fullName.equals(user.fullName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, fullName);
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.time.DayOfWeek;
import java.util.List;
import java.util.Set;

@ParametersAreNonnullByDefault
public interface CourseService {
@@ -50,7 +51,7 @@ public interface CourseService {
     * @param location
     * @return the CourseSectionClass id of new inserted line.
     */
    int addCourseSectionClass(int sectionId, int instructorId, DayOfWeek dayOfWeek, List<Short> weekList,
    int addCourseSectionClass(int sectionId, int instructorId, DayOfWeek dayOfWeek, Set<Short> weekList,
                              short classStart, short classEnd, String location);