Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
group_2-S2-9831067
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
9831067
group_2-S2-9831067
Commits
330110c8
Commit
330110c8
authored
5 years ago
by
9831067
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Last Edit
parents
master
No related merge requests found
Pipeline
#2051
failed with stages
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
221 additions
and
0 deletions
+221
-0
Lab.java
Lab.java
+85
-0
Run.java
Run.java
+28
-0
Student.java
Student.java
+108
-0
No files found.
Lab.java
0 → 100644
View file @
330110c8
public
class
Lab
{
/**
* Create a new lab with a given name and ID number and etc.
*
* @param students collection student
* @param avg of student
* @param day of class
*
*
*/
// collection of students
private
static
Student
[]
students
;
private
static
int
avg
;
private
static
String
day
;
private
static
int
capacity
;
private
static
int
currentSize
;
public
Lab
(
int
capacity
,
String
day
)
{
this
.
capacity
=
capacity
;
students
=
new
Student
[
capacity
];
this
.
day
=
day
;
}
public
void
enrollStudent
(
Student
std
)
{
if
(
currentSize
<
capacity
)
{
students
[
currentSize
]
=
std
;
currentSize
++;
}
else
{
System
.
out
.
println
(
"Lab is full!!!"
);
}
}
public
void
print
()
{
for
(
int
i
=
0
;
i
<
currentSize
;
i
++)
{
System
.
out
.
println
(
"std fname: "
+
students
[
i
].
getFirstName
()
+
" std id:"
+
students
[
i
].
getId
()
+
" std grade:"
+
students
[
i
].
getGrade
());
}
System
.
out
.
println
(
"Lab AVG:"
+
avg
);
}
public
Student
[]
getStudents
()
{
return
students
;
}
public
void
setStudents
(
Student
[]
students
)
{
if
(
students
.
length
>
capacity
)
currentSize
=
capacity
;
else
currentSize
=
students
.
length
;
this
.
students
=
students
;
}
public
int
getAvg
()
{
return
avg
;
}
public
void
calculateAvg
()
{
int
sum
=
0
;
for
(
int
i
=
0
;
i
<
currentSize
;
i
++)
{
sum
+=
students
[
i
].
getGrade
()
;
}
avg
=
sum
/
currentSize
;
}
public
String
getDay
()
{
return
day
;
}
public
void
setDay
(
String
day
)
{
this
.
day
=
day
;
}
public
int
getCapacity
()
{
return
capacity
;
}
public
void
setCapacity
(
int
capacity
)
{
this
.
capacity
=
capacity
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Run.java
0 → 100644
View file @
330110c8
public
class
Run
{
public
static
void
main
(
String
[]
args
)
{
Student
std1
=
new
Student
(
"Ehsan"
,
"Edalat"
,
"9031066"
);
Student
std2
=
new
Student
(
"Seyed"
,
"Ahmadpanah"
,
"9031806"
);
Student
std3
=
new
Student
(
"Ahmad"
,
"Asadi"
,
"9031054"
);
std1
.
print
();
std1
.
setGrade
(
15
);
std1
.
print
();
std2
.
print
();
std2
.
setGrade
(
11
);
std2
.
print
();
std3
.
print
();
std3
.
setFirstName
(
"HamidReza"
);
std3
.
print
();
Lab
lab
=
new
Lab
(
2
,
"1.10.79"
)
;
lab
.
enrollStudent
(
std1
);
lab
.
enrollStudent
(
std2
);
lab
.
enrollStudent
(
std3
);
lab
.
calculateAvg
();
lab
.
print
();
}
}
This diff is collapsed.
Click to expand it.
Student.java
0 → 100644
View file @
330110c8
/**
* The Student class represents a student in a student administration system.
* It holds the student details relevant in our context.
*
* @author Ehsan
* @version 0.0
*/
public
class
Student
{
// the student’s first name
private
String
firstName
;
// the student’s last name
private
String
lastName
;
// the student ID
private
String
id
;
//the grade
private
int
grade
;
/**
* Set a name of student.
* @param sName student
*/
public
void
setFirstName
(
String
str
)
{
firstName
=
str
;
}
/**
* Set a lastName of student.
* @param sLastName student
*/
public
void
setLastName
(
String
str
)
{
lastName
=
str
;
}
/**
* Set a id of student.
* @param sId student
*/
public
void
setId
(
String
str
)
{
id
=
str
;
}
/**
* Print the student’s first name and last name and ID number and grade to the output terminal.
*
*/
public
void
print
()
{
System
.
out
.
println
(
"first name is: "
+
firstName
+
" last name is: "
+
lastName
+
" id is : "
+
id
+
" grade is: "
+
grade
);
}
/**
*
* @param set the grade of student.
*
*/
public
void
setGrade
(
int
s
)
{
grade
=
s
;
}
/**
* get the first name of student
* @return firstName field
*/
public
String
getFirstName
()
{
return
firstName
;
}
/**
* get the last name of student
* @return lastName field
*/
public
String
getLastName
()
{
return
lastName
;
}
/**
* get the id of student
* @return id field
*/
public
String
getId
()
{
return
id
;
}
/**
* get the grade of student
* @return grade field
*/
public
int
getGrade
()
{
return
grade
;
}
/**
* Create a new student with a given name and ID number.
*
* @param fName first name of student
* @param lname last name of student
* @param sID student ID
*/
public
Student
(
String
fName
,
String
lname
,
String
sID
){
firstName
=
fName
;
lastName
=
lname
;
id
=
sID
;
grade
=
0
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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