Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dev-oo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ethan Robert
dev-oo
Commits
07503b30
Commit
07503b30
authored
1 month ago
by
Ethan Robert
Browse files
Options
Downloads
Patches
Plain Diff
Added yearGroup and studentAbs classes
parent
b5186faa
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tp04/StudentAbs.java
+101
-0
101 additions, 0 deletions
src/tp04/StudentAbs.java
src/tp04/YearGroup.java
+54
-0
54 additions, 0 deletions
src/tp04/YearGroup.java
with
155 additions
and
0 deletions
src/tp04/StudentAbs.java
0 → 100644
+
101
−
0
View file @
07503b30
package
tp04
;
public
class
StudentAbs
{
public
final
static
int
thresholdAbs
=
5
;
private
Student
etu
;
private
int
abs
;
public
StudentAbs
(
Person
person
,
double
[]
grades
,
int
abs
)
{
this
.
etu
=
new
Student
(
person
,
grades
);
this
.
abs
=
abs
;
}
public
StudentAbs
(
String
forename
,
String
name
,
double
[]
grades
,
int
abs
)
{
this
.
etu
=
new
Student
(
forename
,
name
,
grades
);
this
.
abs
=
abs
;
}
public
StudentAbs
(
String
forename
,
String
name
,
double
grade
,
int
abs
)
{
this
.
etu
=
new
Student
(
forename
,
name
,
grade
);
this
.
abs
=
abs
;
}
public
StudentAbs
(
String
forename
,
String
name
,
double
grade
)
{
this
.
etu
=
new
Student
(
forename
,
name
,
grade
);
this
.
abs
=
0
;
}
public
String
getName
()
{
return
this
.
etu
.
getName
();
}
public
void
setName
(
String
newName
)
{
this
.
etu
.
setName
(
newName
);
}
public
String
getForename
()
{
return
this
.
etu
.
getForename
();
}
public
void
setForename
(
String
newName
)
{
this
.
etu
.
setForename
(
newName
);
}
public
int
getID
()
{
return
this
.
etu
.
getID
();
}
public
void
addGrade
(
double
grade
)
{
this
.
etu
.
addGrade
(
grade
);
}
public
double
[]
getGrades
()
{
return
this
.
etu
.
getGrades
();
}
public
double
getAverage
()
{
return
this
.
etu
.
getAverage
();
}
public
int
getAbs
()
{
return
this
.
abs
;
}
public
void
incrAbs
()
{
this
.
abs
++;
}
public
String
toString
()
{
return
""
+
this
.
etu
+
", nbAbs="
+
this
.
abs
;
}
public
boolean
equals
(
Object
other
)
{
if
(
other
==
null
)
{
return
false
;
}
if
(
other
.
getClass
()
==
this
.
getClass
())
{
StudentAbs
otherStudentAbs
=
(
StudentAbs
)
other
;
double
[]
thisStudentGrades
=
this
.
etu
.
getGrades
();
boolean
arrayEquals
=
true
;
double
[]
otherStudentGrades
=
otherStudentAbs
.
getGrades
();
if
(
otherStudentGrades
.
length
==
thisStudentGrades
.
length
)
{
for
(
int
i
=
0
;
i
<
thisStudentGrades
.
length
;
i
++)
{
arrayEquals
=
thisStudentGrades
[
i
]
==
otherStudentGrades
[
i
];
}
}
return
this
.
getID
()
==
otherStudentAbs
.
getID
()
&&
arrayEquals
&&
this
.
getAbs
()
==
otherStudentAbs
.
getAbs
();
}
return
false
;
}
public
boolean
warning
()
{
return
this
.
abs
>
StudentAbs
.
thresholdAbs
||
this
.
etu
.
getAverage
()
<
Student
.
thresholdAvg
;
}
public
boolean
validation
()
{
return
!
this
.
warning
();
}
}
This diff is collapsed.
Click to expand it.
src/tp04/YearGroup.java
0 → 100644
+
54
−
0
View file @
07503b30
package
tp04
;
import
java.util.Arrays
;
public
class
YearGroup
{
private
StudentAbs
[]
yg
;
public
YearGroup
()
{
this
.
yg
=
new
StudentAbs
[];
}
public
int
getRealLength
()
{
int
count
=
0
;
for
(
int
i
=
0
;
i
<
this
.
yg
.
length
;
i
++)
{
if
(
this
.
yg
[
i
]
!=
null
)
{
count
++;
}
}
return
count
;
}
public
void
addStudent
(
StudentAbs
student
)
{
if
(
this
.
yg
.
length
!=
this
.
getRealLength
())
{
for
(
int
i
=
0
;
i
<
this
.
yg
.
length
;
i
++)
{
if
(
this
.
yg
[
i
]
==
null
)
{
this
.
yg
[
i
]
=
student
;
}
}
}
else
{
this
.
yg
=
Arrays
.
copyOf
(
this
.
yg
,
this
.
yg
.
length
+
1
);
this
.
yg
[
this
.
yg
.
length
-
1
]
=
student
;
}
}
public
void
addStudent
(
StudentAbs
[]
students
)
{
for
(
int
i
=
0
;
i
<
students
.
length
;
i
++)
{
this
.
addStudent
(
students
[
i
]);
}
}
public
void
addGrades
(
double
[]
grades
)
{
for
(
int
i
=
0
;
i
<
grades
.
length
;
i
++)
{
this
.
yg
[
i
].
addGrade
(
grades
[
i
]);
}
}
public
void
validation
()
{
for
(
int
i
=
0
;
i
<
this
.
yg
.
length
;
i
++)
{
if
(
this
.
yg
[
i
].
validation
())
{
System
.
out
.
println
(
this
.
yg
[
i
]);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment