Commit 422ec95f authored by 9731087's avatar 9731087

First commit

parent 2052d3de
package Test;
import com.university.Course;
import com.university.Department;
import com.university.Professor;
import com.university.Student;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class CourseTest {
static Student student;
static Department department;
static Course course;
static Professor professor;
@BeforeAll
public static void creatCourse (){
department = new Department("ce");
student = new Student("Amir", "87", "am", department);
professor = new Professor(department, "mmd");
course = new Course("1", "az", department, professor, 100);
}
@Test
public void testCourse(){
assertEquals("az", course.getName());
assertEquals("1", course.getID());
assertEquals("100", course.getCredit());
assertEquals(department, course.getDepartment());
assertEquals(professor, course.getProfessor());
assertEquals(student, course.getStudents());
}
}
\ No newline at end of file
package Test;
import com.university.Course;
import com.university.Department;
import com.university.Professor;
import com.university.Student;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class DepartmentTest {
static Department department;
static Student student;
static Course course;
static Professor professor;
@BeforeAll
public static void departmentCreat() {
department = new Department("ce");
student = new Student("Amir", "87", "am", department);
professor = new Professor(department, "mmd");
course = new Course("1", "az", department, professor, 100);
}
@Test
public void testDepartment(){
}
}
\ No newline at end of file
package Test;
import com.university.Course;
import com.university.Department;
import com.university.Professor;
import com.university.Student;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class ProfessorTest {
static Department department;
static Student student;
static Course course;
static Professor professor;
@BeforeAll
public static void creatProfessor() {
department = new Department("ce");
student = new Student("Amir", "87", "am", department);
professor = new Professor(department, "mmd");
course = new Course("1", "az", department, professor, 100);
department.addCourse(course);
department.addProfessor(professor);
department.addStudent(student);
}
@Test
public void testProfessor() {
assertEquals("mmd", professor.getName());
assertEquals(department, professor.getDepartment());
}
}
\ No newline at end of file
package Test;
import com.university.Course;
import com.university.Department;
import com.university.Professor;
import com.university.Student;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class StudentTest {
static Student student;
static Department department;
static Course course;
static Professor professor;
@BeforeAll
public static void creatStudent() {
department = new Department("CE");
student = new Student("Amir", "87", "am", department);
course = new Course("1", "az", department, professor, 100);
}
@Test
public static void testName() {
assertEquals("Amir", student.getName());
assertEquals("87", student.getID());
assertEquals("ce", student.getMajor());
assertEquals(department, student.getDepartment());
assertEquals(course, student.getCourses());
}
}
\ No newline at end of file
package Test;
import static org.junit.jupiter.api.Assertions.*;
class UniversityTest {
}
\ No newline at end of file
package com.university;
import java.util.ArrayList;
public class Course {
String id;
String name;
Department department;
Professor professor;
int credit;
ArrayList<Student> students = new ArrayList<>();
public Course(String ID, String name, Department department, Professor professor, int credit) {
}
public String getID(){
return this.id;
}
public Department getDepartment(){
return this.department;
}
public String getName() {
return this.name;
}
public ArrayList<Student> getStudents() {
return this.students;
}
public Professor getProfessor() {
return this.professor;
}
public int getCredit() {
return this.credit;
}
public void enrollStudent(Student student){
this.students.add(student);
}
}
package com.university;
import java.util.ArrayList;
public class Department {
String name;
ArrayList<Student> students = new ArrayList();
ArrayList<Course> courses = new ArrayList<>();
ArrayList<Professor> professors = new ArrayList<>();
public Department(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void addStudent(Student student) {
this.students.add(student);
}
public ArrayList<Student> getStudents() {
return this.students;
}
public void removeStudent(Student student) {
this.students.remove(student);
}
public void addCourse(Course course) {
this.courses.add(course);
}
public ArrayList<Course> getCourses() {
return this.courses;
}
public void removeCourse(Course course) {
this.courses.remove(course);
}
public void addProfessor(Professor professor) {
this.professors.add(professor);
}
public ArrayList<Professor> getProfessors() {
return this.professors;
}
public void removeProfessor(Professor professor) {
this.professors.remove(professor);
}
}
package com.university;
import java.util.ArrayList;
public class Professor {
Department department;
String name;
ArrayList<Course> courses = new ArrayList<>();
public Professor(Department department, String name) {
this.department = department;
this.name = name;
}
public Department getDepartment() {
return this.department;
}
public String getName() {
return this.name;
}
public ArrayList<Course> getCourses() {
return this.courses;
}
}
package com.university;
import java.util.ArrayList;
public class Student {
String name;
String id;
String major;
Department department;
ArrayList<Course> courses = new ArrayList<>();
public Student(String name, String ID, String major, Department department) {
this.name = name;
this.id = ID;
this.major = major;
this.department = department;
}
public String getName() {
return this.name;
}
public String getID() {
return this.id;
}
public String getMajor() {
return this.major;
}
public Department getDepartment() {
return this.department;
}
public ArrayList<Course> getCourses() {
return this.courses;
}
public void addCourse(Course course) {
this.courses.add(course);
}
}
package com.university;
import java.util.ArrayList;
public class University {
ArrayList<Department> departments = new ArrayList<>();
public ArrayList<Department> getDepartments() {
return this.departments;
}
public void addDepartment(Department department) {
this.departments.add(department);
}
public void removeDepartment(Department department) {
this.departments.remove(department);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment