Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
lab6_deadline
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
9531304
lab6_deadline
Commits
c47796bc
Commit
c47796bc
authored
May 19, 2019
by
9531304
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
the first part
parents
Pipeline
#639
failed with stages
Changes
9
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
319 additions
and
0 deletions
+319
-0
StudentTest.java
src/StudentTest.java
+34
-0
Course.java
src/com/university/Course.java
+51
-0
Department.java
src/com/university/Department.java
+49
-0
Professor.java
src/com/university/Professor.java
+26
-0
Student.java
src/com/university/Student.java
+47
-0
StudnetTest.java
src/com/university/StudnetTest.java
+32
-0
University.java
src/com/university/University.java
+11
-0
test.java
src/com/university/test.java
+10
-0
StudnetTest.java
src/test/StudnetTest.java
+59
-0
No files found.
src/StudentTest.java
0 → 100644
View file @
c47796bc
import
com.university.Department
;
import
com.university.Student
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.jupiter.api.BeforeAll
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
public
class
StudentTest
{
static
Student
student
;
static
Department
department
;
@BeforeAll
public
static
void
createStudent
(){
department
=
new
Department
(
"Computer and IT Eng"
);
student
=
new
Student
(
"Alireza"
,
"1234"
,
"Software Eng"
,
department
);
}
@Test
public
void
testStudentGetName
(){
assertEquals
(
"Alireza"
,
student
.
getName
());
}
@Test
public
void
testStudenGetCourses
(){
assertNotNull
(
student
.
getCourses
());
assertEquals
(
0
,
student
.
getCourses
().
length
);
}
}
src/com/university/Course.java
0 → 100644
View file @
c47796bc
package
com
.
university
;
import
java.util.ArrayList
;
public
class
Course
{
private
String
ID
;
private
String
name
;
private
Department
dpart
;
private
Professor
prof
;
private
int
credit
;
private
ArrayList
<
Student
>
stds
=
new
ArrayList
<
Student
>();
public
Course
(
String
ID
,
String
name
,
Department
department
,
Professor
professor
,
int
credit
)
{
this
.
ID
=
ID
;
this
.
name
=
name
;
dpart
=
department
;
prof
=
professor
;
this
.
credit
=
credit
;
}
public
String
getID
(){
return
ID
;
}
public
Department
getDepartment
(){
return
dpart
;
}
public
String
getName
()
{
return
name
;
}
public
Student
[]
getStudents
()
{
Student
[]
students
=
stds
.
toArray
(
new
Student
[
stds
.
size
()]);
return
students
;
}
public
Professor
getProfessor
()
{
return
prof
;
}
public
int
getCredit
()
{
return
credit
;
}
public
void
enrollStudent
(
Student
student
){
stds
.
add
(
student
);
}
}
src/com/university/Department.java
0 → 100644
View file @
c47796bc
package
com
.
university
;
public
class
Department
{
private
String
name
;
public
Department
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getName
(){
return
name
;
}
public
void
addStudent
(
Student
student
){
}
public
Student
[]
getStudents
(){
return
null
;
}
public
void
removeStudent
(
Student
student
){
}
public
void
addCourse
(
Course
course
){
}
public
Course
[]
getCourses
(){
return
null
;
}
public
void
removeCourse
(
Course
course
){
}
public
void
addProfessor
(
Professor
student
){
}
public
Professor
[]
getProfessors
(){
return
null
;
}
public
void
removeProfessor
(
Professor
professor
){
}
}
src/com/university/Professor.java
0 → 100644
View file @
c47796bc
package
com
.
university
;
import
java.util.ArrayList
;
public
class
Professor
{
private
String
name
;
private
Department
dpart
;
private
ArrayList
<
Course
>
crs
=
new
ArrayList
<
Course
>();
public
Professor
(
Department
department
,
String
name
)
{
this
.
name
=
name
;
dpart
=
department
;
}
public
Department
getDepartment
()
{
return
dpart
;
}
public
String
getName
()
{
return
name
;
}
public
Course
[]
getCourses
()
{
return
null
;
}
}
src/com/university/Student.java
0 → 100644
View file @
c47796bc
package
com
.
university
;
import
java.util.ArrayList
;
public
class
Student
{
private
String
name
;
private
String
ID
;
private
String
major
;
private
Department
dpart
;
private
ArrayList
<
Course
>
crss
=
new
ArrayList
<
Course
>();
public
Student
(
String
name
,
String
ID
,
String
major
,
Department
department
)
{
this
.
name
=
name
;
this
.
ID
=
ID
;
this
.
major
=
major
;
dpart
=
department
;
}
public
String
getName
()
{
return
name
;
}
public
String
getID
()
{
return
ID
;
}
public
String
getMajor
()
{
return
major
;
}
public
Department
getDepartment
()
{
return
dpart
;
}
public
Course
[]
getCourses
()
{
Course
[]
courses
=
crss
.
toArray
(
new
Course
[
crss
.
size
()]);
return
courses
;
}
public
void
addCourse
(
Course
course
){
if
(
course
!=
null
)
{
crss
.
add
(
course
);
}
}
}
src/com/university/StudnetTest.java
0 → 100644
View file @
c47796bc
package
com
.
university
;
import
org.junit.Test
;
import
org.junit.jupiter.api.BeforeAll
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
public
class
StudnetTest
{
static
Student
student
;
static
Department
department
;
@BeforeAll
public
static
void
createStudent
(){
department
=
new
Department
(
"Computer and IT Eng"
);
student
=
new
Student
(
"Alireza"
,
"1234"
,
"Software Eng"
,
department
);
}
@Test
public
void
testStudentGetName
(){
assertEquals
(
"Alireza"
,
student
.
getName
());
}
@Test
public
void
testStudenGetCourses
(){
assertNotNull
(
student
.
getCourses
());
assertEquals
(
0
,
student
.
getCourses
().
length
);
}
}
src/com/university/University.java
0 → 100644
View file @
c47796bc
package
com
.
university
;
public
class
University
{
public
Department
[]
getDepartments
(){
return
null
;
}
public
void
addDepartment
(
Department
department
){
}
public
void
removeDepartment
(
Department
department
){
}
}
src/com/university/test.java
0 → 100644
View file @
c47796bc
package
com
.
university
;
public
class
test
{
public
static
void
main
(
String
[]
args
){
Department
dp
=
new
Department
(
"amirkabir"
);
Student
st
=
new
Student
(
"Mohammad"
,
"1234"
,
"Mechanic"
,
dp
);
System
.
out
.
println
(
st
.
getName
());
}
}
src/test/StudnetTest.java
0 → 100644
View file @
c47796bc
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
junit
.
framework
.
TestCase
.
assertEquals
;
import
static
junit
.
framework
.
TestCase
.
assertNotNull
;
public
class
StudnetTest
{
static
Student
student
,
student1
;
static
Department
department
;
static
Professor
prf
;
@BeforeAll
public
static
void
createStudent
(){
department
=
new
Department
(
"Computer and IT Eng"
);
student
=
new
Student
(
"Alireza"
,
"1234"
,
"Software Eng"
,
department
);
prf
=
new
Professor
(
department
,
"Ohadi"
);
Course
c1
=
new
Course
(
"12"
,
"mathematic"
,
department
,
prf
,
1
);
Course
c2
=
new
Course
(
"14"
,
"Physic"
,
department
,
prf
,
2
);
student1
=
new
Student
(
"Mohammad"
,
"4321"
,
"Mechanic"
,
department
);
student1
.
addCourse
(
null
);
}
@Test
public
void
testStudentGetName
(){
assertEquals
(
"Alireza"
,
student
.
getName
());
}
@Test
public
void
testStudenGetCourses
(){
assertNotNull
(
student
.
getCourses
());
assertEquals
(
0
,
student
.
getCourses
().
length
);
}
@Test
public
void
testStudentID
(){
assertNotNull
(
student
.
getID
());
}
@Test
public
void
testStudentDepartment
(){
assertNotNull
(
student
.
getDepartment
());
}
@Test
public
void
testStudentMajor
(){
assertNotNull
(
student
.
getMajor
());
}
@Test
public
void
testStudentNullCourse
(){
assertEquals
(
0
,
student1
.
getCourses
().
length
);
}
}
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