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
37feb3ae
Commit
37feb3ae
authored
Apr 14, 2019
by
9731050
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last change
parent
ae6d61e4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
4 deletions
+31
-4
Professor.java
src/com/university/Professor.java
+4
-0
University.java
src/com/university/University.java
+4
-1
ProfessorTest.java
src/test/ProfessorTest.java
+14
-2
UniversityTest.java
src/test/UniversityTest.java
+9
-1
No files found.
src/com/university/Professor.java
View file @
37feb3ae
...
...
@@ -20,6 +20,10 @@ public class Professor {
return
this
.
name
;
}
public
void
setCourses
(
Course
courses
){
if
(
getDepartment
().
getName
().
compareTo
(
courses
.
getDepartment
().
getName
())==
0
)
this
.
courses
.
add
(
courses
);
}
public
ArrayList
<
Course
>
getCourses
()
{
return
courses
;
}
...
...
src/com/university/University.java
View file @
37feb3ae
...
...
@@ -3,7 +3,10 @@ package com.university;
import
java.util.ArrayList
;
public
class
University
{
private
ArrayList
<
Department
>
departments
=
new
ArrayList
<
Department
>();
private
ArrayList
<
Department
>
departments
;
public
University
(){
departments
=
new
ArrayList
<
Department
>();
}
public
ArrayList
<
Department
>
getDepartments
(){
return
departments
;
}
...
...
src/test/ProfessorTest.java
View file @
37feb3ae
...
...
@@ -7,23 +7,35 @@ 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
ProfessorTest
{
static
Department
department
;
static
Student
student
;
static
Course
course
;
static
Course
course
,
c2
,
c1
;
static
Professor
professor
;
static
ArrayList
<
Course
>
courses
;
@BeforeAll
public
static
void
creatStudent
()
{
courses
=
new
ArrayList
<>();
department
=
new
Department
(
"abc"
);
professor
=
new
Professor
(
department
,
"kz"
);
c2
=
new
Course
(
"125"
,
"math"
,
new
Department
(
"ss"
),
professor
,
1
);
c1
=
new
Course
(
"124"
,
"math"
,
department
,
professor
,
1
);
course
=
new
Course
(
"123"
,
"ap"
,
department
,
professor
,
2
);
professor
.
setCourses
(
c2
);
professor
.
setCourses
(
course
);
professor
.
setCourses
(
c1
);
for
(
int
i
=
0
;
i
<
professor
.
getCourses
().
size
();
i
++)
courses
.
add
(
professor
.
getCourses
().
get
(
i
));
}
@Test
public
void
Test
(){
assertEquals
(
department
,
professor
.
getDepartment
());
assertEquals
(
"kz"
,
professor
.
getName
());
assertEquals
(
courses
,
professor
.
getCourses
());
}
}
src/test/UniversityTest.java
View file @
37feb3ae
...
...
@@ -4,6 +4,8 @@ import com.university.*;
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
UniversityTest
{
...
...
@@ -12,16 +14,22 @@ public class UniversityTest {
static
Course
course
;
static
Professor
professor
;
static
University
university
;
static
ArrayList
<
Department
>
departments
;
@BeforeAll
public
static
void
creatStudent
()
{
departments
=
new
ArrayList
<>();
department
=
new
Department
(
"abc"
);
university
=
new
University
();
university
.
addDepartment
(
department
);
for
(
int
i
=
0
;
i
<
university
.
getDepartments
().
size
();
i
++)
departments
.
add
(
university
.
getDepartments
().
get
(
i
));
}
@Test
public
void
Test
(){
assertEquals
(
department
,
university
.
getDepartments
().
get
(
0
));
university
.
removeDepartment
(
department
);
assertEquals
(
0
,
university
.
getDepartments
().
get
(
0
));
departments
.
remove
(
department
);
assertEquals
(
departments
,
university
.
getDepartments
());
}
}
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