Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lab6
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9731050
Lab6
Commits
ae6d61e4
Commit
ae6d61e4
authored
Apr 14, 2019
by
9731050
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3th
parent
1ab10fd8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
Department.java
src/com/university/Department.java
+1
-0
DepartmentTest.java
src/test/DepartmentTest.java
+28
-10
No files found.
src/com/university/Department.java
View file @
ae6d61e4
...
...
@@ -12,6 +12,7 @@ public class Department {
this
.
name
=
name
;
students
=
new
ArrayList
<
Student
>();
courses
=
new
ArrayList
<
Course
>();
professors
=
new
ArrayList
<
Professor
>();
}
public
String
getName
(){
...
...
src/test/DepartmentTest.java
View file @
ae6d61e4
...
...
@@ -7,36 +7,54 @@ import com.university.Student;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.Test
;
import
java.util.ArrayList
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
public
class
DepartmentTest
{
static
Department
department
;
static
Student
student
;
static
Course
course
;
static
Professor
professor
;
static
Student
student
,
s2
;
static
Course
course
,
c2
;
static
Professor
professor
,
p2
;
static
ArrayList
<
Course
>
courses
;
static
ArrayList
<
Professor
>
professors
;
static
ArrayList
<
Student
>
students
;
@BeforeAll
public
static
void
creatStudent
()
{
courses
=
new
ArrayList
<>();
professors
=
new
ArrayList
<>();
students
=
new
ArrayList
<>();
department
=
new
Department
(
"abc"
);
professor
=
new
Professor
(
department
,
"kz"
);
course
=
new
Course
(
"123"
,
"math"
,
department
,
professor
,
3
);
student
=
new
Student
(
"ali"
,
"1234"
,
"abc"
,
department
);
s2
=
new
Student
(
"Mohammad"
,
"124"
,
"b"
,
new
Department
(
"aa"
));
department
.
addCourse
(
course
);
department
.
addProfessor
(
professor
);
department
.
addStudent
(
student
);
department
.
addStudent
(
s2
);
for
(
int
i
=
0
;
i
<
department
.
getStudents
().
size
();
i
++)
students
.
add
(
department
.
getStudents
().
get
(
i
));
for
(
int
j
=
0
;
j
<
department
.
getProfessors
().
size
();
j
++)
professors
.
add
(
department
.
getProfessors
().
get
(
j
));
for
(
int
z
=
0
;
z
<
department
.
getCourses
().
size
();
z
++)
courses
.
add
(
department
.
getCourses
().
get
(
z
));
}
@Test
public
void
Test
(){
assertEquals
(
"abc"
,
department
.
getName
());
assertEquals
(
professor
,
department
.
getProfessors
().
get
(
0
));
assertEquals
(
course
,
department
.
getCourses
().
get
(
0
));
assertEquals
(
student
,
department
.
getStudents
().
get
(
0
));
assertEquals
(
professor
s
,
department
.
getProfessors
(
));
assertEquals
(
course
s
,
department
.
getCourses
(
));
assertEquals
(
student
s
,
department
.
getStudents
(
));
department
.
removeCourse
(
course
);
courses
.
remove
(
course
);
department
.
removeProfessor
(
professor
);
professors
.
remove
(
professor
);
department
.
removeStudent
(
student
);
assertEquals
(
0
,
department
.
getProfessors
().
get
(
0
));
assertEquals
(
0
,
department
.
getCourses
().
get
(
0
));
assertEquals
(
0
,
department
.
getStudents
().
get
(
0
));
students
.
remove
(
student
);
assertEquals
(
professors
,
department
.
getProfessors
());
assertEquals
(
courses
,
department
.
getCourses
());
assertEquals
(
students
,
department
.
getStudents
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment