Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lab66
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
9731088
Lab66
Commits
fbde3cbd
Commit
fbde3cbd
authored
Apr 14, 2019
by
Roham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
YOLO
parent
d13886c8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
211 additions
and
22 deletions
+211
-22
Course.java
src/com/university/Course.java
+25
-8
Department.java
src/com/university/Department.java
+3
-3
Student.java
src/com/university/Student.java
+24
-8
University.java
src/com/university/University.java
+1
-1
CourseTest.java
src/test/CourseTest.java
+32
-1
DepartmentTest.java
src/test/DepartmentTest.java
+42
-0
ProfessorTest.java
src/test/ProfessorTest.java
+31
-0
StudentTest.java
src/test/StudentTest.java
+27
-1
UniversityTest.java
src/test/UniversityTest.java
+26
-0
No files found.
src/com/university/Course.java
View file @
fbde3cbd
package
com
.
university
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Course
{
String
ID
;
String
name
;
Department
department
;
Professor
professor
;
List
<
Student
>
students
;
int
credit
;
public
Course
(
String
ID
,
String
name
,
Department
department
,
Professor
professor
,
int
credit
)
{
this
.
ID
=
ID
;
this
.
name
=
name
;
this
.
department
=
department
;
this
.
professor
=
professor
;
this
.
credit
=
credit
;
this
.
students
=
new
ArrayList
<>();
}
public
String
getID
(){
return
null
;
return
this
.
ID
;
}
public
Department
getDepartment
(){
return
null
;
return
this
.
department
;
}
public
String
getName
()
{
return
null
;
return
this
.
name
;
}
public
Student
[]
getStudents
()
{
return
null
;
Student
[]
std
=
new
Student
[
this
.
students
.
size
()];
for
(
int
i
=
0
;
i
<
this
.
students
.
size
();
i
++)
std
[
i
]
=
this
.
students
.
get
(
i
);
return
std
;
}
public
Professor
getProfessor
()
{
return
null
;
return
this
.
professor
;
}
public
int
getCredit
()
{
return
0
;
return
this
.
credit
;
}
public
void
enrollStudent
(
Student
student
){
if
(
student
.
getDepartment
().
getName
().
equals
(
this
.
department
.
getName
()))
this
.
students
.
add
(
student
);
}
}
src/com/university/Department.java
View file @
fbde3cbd
...
...
@@ -25,7 +25,7 @@ public class Department {
}
public
Student
[]
getStudents
(){
return
(
Student
[])
this
.
students
.
toArray
(
);
return
this
.
students
.
toArray
(
new
Student
[
this
.
students
.
size
()]
);
}
public
void
removeStudent
(
Student
student
){
...
...
@@ -37,7 +37,7 @@ public class Department {
}
public
Course
[]
getCourses
(){
return
(
Course
[])
this
.
courses
.
toArray
(
);
return
this
.
courses
.
toArray
(
new
Course
[
this
.
courses
.
size
()]
);
}
public
void
removeCourse
(
Course
course
){
...
...
@@ -49,7 +49,7 @@ public class Department {
}
public
Professor
[]
getProfessors
(){
return
(
Professor
[])
this
.
professors
.
toArray
(
);
return
this
.
professors
.
toArray
(
new
Professor
[
this
.
professors
.
size
()]
);
}
public
void
removeProfessor
(
Professor
professor
){
...
...
src/com/university/Student.java
View file @
fbde3cbd
package
com
.
university
;
public
class
Student
{
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Student
{
String
Name
;
String
ID
;
String
major
;
Department
department
;
List
<
Course
>
courses
;
public
Student
(
String
name
,
String
ID
,
String
major
,
Department
department
)
{
this
.
Name
=
name
;
this
.
ID
=
ID
;
this
.
major
=
major
;
this
.
department
=
department
;
this
.
courses
=
new
ArrayList
<>();
}
public
String
getName
()
{
return
null
;
return
this
.
Name
;
}
public
String
getID
()
{
return
null
;
return
this
.
ID
;
}
public
String
getMajor
()
{
return
null
;
return
this
.
major
;
}
public
Department
getDepartment
()
{
return
null
;
return
this
.
department
;
}
public
Course
[]
getCourses
()
{
return
null
;
Course
[]
crs
=
new
Course
[
this
.
courses
.
size
()];
for
(
int
i
=
0
;
i
<
this
.
courses
.
size
();
i
++)
{
crs
[
i
]
=
this
.
courses
.
get
(
i
);
}
return
crs
;
}
public
void
addCourse
(
Course
course
){
this
.
courses
.
add
(
course
);
}
}
src/com/university/University.java
View file @
fbde3cbd
...
...
@@ -6,7 +6,7 @@ import java.util.List;
public
class
University
{
List
<
Department
>
departments
=
new
ArrayList
<>();
public
Department
[]
getDepartments
(){
return
(
Department
[])
this
.
departments
.
toArray
(
);
return
this
.
departments
.
toArray
(
new
Department
[
this
.
departments
.
size
()]
);
}
public
void
addDepartment
(
Department
department
){
this
.
departments
.
add
(
department
);}
...
...
src/test/CourseTest.java
View file @
fbde3cbd
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
Department
department
;
static
Professor
professor
;
static
Course
course
;
static
Student
student
;
@BeforeAll
public
static
void
createCourse
()
{
department
=
new
Department
(
"Computer"
);
professor
=
new
Professor
(
department
,
"Gholam"
);
student
=
new
Student
(
"Roham"
,
"1"
,
"Software Eng"
,
department
);
course
=
new
Course
(
"1"
,
"AP"
,
department
,
professor
,
0
);
course
.
enrollStudent
(
student
);
}
@Test
public
void
testCourse
()
{
assertEquals
(
"1"
,
course
.
getID
());
assertEquals
(
"AP"
,
course
.
getName
());
assertEquals
(
department
,
course
.
getDepartment
());
assertEquals
(
professor
,
course
.
getProfessor
());
assertEquals
(
0
,
course
.
getCredit
());
assertEquals
(
student
,
course
.
getStudents
()[
0
]);
}
}
\ No newline at end of file
src/test/DepartmentTest.java
0 → 100644
View file @
fbde3cbd
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
Professor
professor
;
static
Course
course
;
static
Student
student
;
@BeforeAll
public
static
void
createDepartment
()
{
department
=
new
Department
(
"Computer"
);
professor
=
new
Professor
(
department
,
"Gholam"
);
student
=
new
Student
(
"Roham"
,
"1"
,
"Software Eng"
,
department
);
course
=
new
Course
(
"1"
,
"AP"
,
department
,
professor
,
0
);
department
.
addStudent
(
student
);
department
.
addCourse
(
course
);
department
.
addProfessor
(
professor
);
}
@Test
public
void
testDepartment
()
{
assertEquals
(
"Computer"
,
department
.
getName
());
assertEquals
(
course
,
department
.
getCourses
()[
0
]);
assertEquals
(
student
,
department
.
getStudents
()[
0
]);
assertEquals
(
professor
,
department
.
getProfessors
()[
0
]);
department
.
removeCourse
(
course
);
department
.
removeProfessor
(
professor
);
department
.
removeStudent
(
student
);
assertEquals
(
0
,
department
.
getCourses
().
length
);
assertEquals
(
0
,
department
.
getStudents
().
length
);
assertEquals
(
0
,
department
.
getProfessors
().
length
);
}
}
\ No newline at end of file
src/test/ProfessorTest.java
0 → 100644
View file @
fbde3cbd
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
Professor
professor
;
static
Course
course
;
static
Student
student
;
@BeforeAll
public
static
void
createProfessor
()
{
department
=
new
Department
(
"Computer"
);
professor
=
new
Professor
(
department
,
"Gholam"
);
student
=
new
Student
(
"Roham"
,
"1"
,
"Software Eng"
,
department
);
course
=
new
Course
(
"1"
,
"AP"
,
department
,
professor
,
0
);
}
@Test
public
void
testProfessor
()
{
assertEquals
(
"Gholam"
,
professor
.
getName
());
assertEquals
(
department
,
professor
.
getDepartment
());
}
}
\ No newline at end of file
src/test/StudentTest.java
View file @
fbde3cbd
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
c1
;
@BeforeAll
public
static
void
createStudent
(){
department
=
new
Department
(
"Computer and IT Eng"
);
student
=
new
Student
(
"Roham"
,
"1"
,
"Software Eng"
,
department
);
c1
=
new
Course
(
"1"
,
"AP"
,
department
,
new
Professor
(
department
,
"Gholam"
),
0
);
student
.
addCourse
(
c1
);
}
@Test
public
void
testStudentGetName
(){
assertEquals
(
"Roham"
,
student
.
getName
());
assertEquals
(
"1"
,
student
.
getID
());
assertEquals
(
"Software Eng"
,
student
.
getMajor
());
assertEquals
(
department
,
student
.
getDepartment
());
assertEquals
(
c1
,
student
.
getCourses
()[
0
]);
}
}
\ No newline at end of file
src/test/UniversityTest.java
0 → 100644
View file @
fbde3cbd
package
test
;
import
com.university.*
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
class
UniversityTest
{
static
Department
department
;
static
University
university
;
@BeforeAll
public
static
void
createUniversity
()
{
department
=
new
Department
(
"Computer"
);
university
=
new
University
();
university
.
addDepartment
(
department
);
}
@Test
public
void
testUniversity
()
{
assertEquals
(
department
,
university
.
getDepartments
()[
0
]);
university
.
removeDepartment
(
department
);
assertEquals
(
0
,
university
.
getDepartments
().
length
);
}
}
\ No newline at end of file
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