Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZZ3-CPP-TP5
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas MURILLON
ZZ3-CPP-TP5
Commits
b9277049
Commit
b9277049
authored
Nov 9, 2021
by
nimurillon
Browse files
Options
Downloads
Patches
Plain Diff
Avant derniere question
parent
b83ed283
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/histogramme.hpp
+33
-2
33 additions, 2 deletions
src/histogramme.hpp
src/valeur.cpp
+17
-1
17 additions, 1 deletion
src/valeur.cpp
src/valeur.hpp
+8
-1
8 additions, 1 deletion
src/valeur.hpp
test/tp5_test.cpp
+12
-14
12 additions, 14 deletions
test/tp5_test.cpp
with
70 additions
and
18 deletions
src/histogramme.hpp
+
33
−
2
View file @
b9277049
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include
<set>
#include
<set>
#include
<functional>
#include
<functional>
#include
<iostream>
#include
<iostream>
#include
<map>
/* class Histogramme {
/* class Histogramme {
double _inf;
double _inf;
...
@@ -30,6 +31,7 @@ class Histogramme
...
@@ -30,6 +31,7 @@ class Histogramme
double
_sup
;
double
_sup
;
double
_step
;
double
_step
;
std
::
set
<
Classe
,
COMP
>
set
;
std
::
set
<
Classe
,
COMP
>
set
;
std
::
multimap
<
Classe
,
Valeur
>
map
;
public:
public:
template
<
typename
>
friend
class
Histogramme
;
template
<
typename
>
friend
class
Histogramme
;
...
@@ -37,8 +39,10 @@ public:
...
@@ -37,8 +39,10 @@ public:
Histogramme
(
double
,
double
,
int
);
Histogramme
(
double
,
double
,
int
);
template
<
typename
T2
>
template
<
typename
T2
>
Histogramme
(
Histogramme
<
T2
>
const
&
h2
);
Histogramme
(
Histogramme
<
T2
>
const
&
h2
);
std
::
set
<
Classe
,
COMP
>
&
getClasses
();
const
std
::
set
<
Classe
,
COMP
>
&
getClasses
()
const
;
void
ajouter
(
double
);
void
ajouter
(
double
);
const
std
::
multimap
<
Classe
,
Valeur
>
&
getValeurs
()
const
;
auto
getValeurs
(
const
Classe
&
)
const
;
};
};
template
<
typename
COMP
>
template
<
typename
COMP
>
...
@@ -59,7 +63,7 @@ Histogramme<COMP>::Histogramme(Histogramme<T2> const & h2) : _inf(h2._inf), _sup
...
@@ -59,7 +63,7 @@ Histogramme<COMP>::Histogramme(Histogramme<T2> const & h2) : _inf(h2._inf), _sup
}
}
template
<
typename
COMP
>
template
<
typename
COMP
>
std
::
set
<
Classe
,
COMP
>
&
Histogramme
<
COMP
>::
getClasses
()
const
std
::
set
<
Classe
,
COMP
>
&
Histogramme
<
COMP
>::
getClasses
()
const
{
{
return
set
;
return
set
;
}
}
...
@@ -85,6 +89,33 @@ void Histogramme<COMP>::ajouter(double d)
...
@@ -85,6 +89,33 @@ void Histogramme<COMP>::ajouter(double d)
c
.
ajouter
();
c
.
ajouter
();
set
.
erase
(
it
);
set
.
erase
(
it
);
set
.
insert
(
c
);
set
.
insert
(
c
);
map
.
insert
(
std
::
pair
<
Classe
,
Valeur
>
(
c
,
Valeur
(
d
)));
}
}
template
<
typename
COMP
>
const
std
::
multimap
<
Classe
,
Valeur
>
&
Histogramme
<
COMP
>::
getValeurs
()
const
{
return
map
;
}
template
<
typename
COMP
>
auto
Histogramme
<
COMP
>::
getValeurs
(
const
Classe
&
c
)
const
{
return
std
::
equal_range
(
map
.
begin
(),
map
.
end
(),
c
);
}
bool
operator
<
(
const
std
::
pair
<
Classe
,
Valeur
>
&
p1
,
const
Classe
&
c
)
{
return
p1
.
first
.
getBorneInf
()
<
c
.
getBorneInf
();
}
bool
operator
<
(
const
Classe
&
c
,
const
std
::
pair
<
Classe
,
Valeur
>
&
p1
)
{
return
p1
.
first
.
getBorneInf
()
>
c
.
getBorneInf
();
}
/* bool operator==(const std::pair<Classe, Valeur> & p1, const Classe& c) {
return p1.first.getBorneInf() == Approx(c.getBorneInf());
}
bool operator==(const Classe& c, const std::pair<Classe, Valeur> & p1) {
return p1.first.getBorneInf() == Approx(c.getBorneInf());
} */
#endif
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/valeur.cpp
+
17
−
1
View file @
b9277049
#include
"valeur.hpp"
#include
"valeur.hpp"
Valeur
::
Valeur
(
double
nombre
)
:
_nombre
(
nombre
)
{}
Valeur
::
Valeur
(
double
nombre
,
std
::
string
nom
)
:
_nombre
(
nombre
)
,
etudiant
(
nom
)
{}
const
double
Valeur
::
getNombre
()
const
{
const
double
Valeur
::
getNombre
()
const
{
return
_nombre
;
return
_nombre
;
...
@@ -9,3 +9,19 @@ const double Valeur::getNombre() const {
...
@@ -9,3 +9,19 @@ const double Valeur::getNombre() const {
void
Valeur
::
setNombre
(
double
nombre
)
{
void
Valeur
::
setNombre
(
double
nombre
)
{
_nombre
=
nombre
;
_nombre
=
nombre
;
}
}
double
Valeur
::
getNote
()
const
{
return
_nombre
;
}
const
std
::
string
&
Valeur
::
getEtudiant
()
const
{
return
etudiant
;
}
void
Valeur
::
setNote
(
double
note
)
{
_nombre
=
note
;
}
void
Valeur
::
setEtudiant
(
const
std
::
string
&
e
)
{
etudiant
=
e
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/valeur.hpp
+
8
−
1
View file @
b9277049
#ifndef VALEUR
#ifndef VALEUR
#define VALEUR
#define VALEUR
#include
<string>
class
Valeur
{
class
Valeur
{
double
_nombre
;
double
_nombre
;
std
::
string
etudiant
;
public:
public:
Valeur
(
double
=
0.0
);
Valeur
(
double
=
0.0
,
std
::
string
=
"inconnu"
);
const
double
getNombre
()
const
;
const
double
getNombre
()
const
;
void
setNombre
(
double
);
void
setNombre
(
double
);
double
getNote
()
const
;
const
std
::
string
&
getEtudiant
()
const
;
void
setNote
(
double
);
void
setEtudiant
(
const
std
::
string
&
);
};
};
#endif
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/tp5_test.cpp
+
12
−
14
View file @
b9277049
...
@@ -306,7 +306,7 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
...
@@ -306,7 +306,7 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
}
}
//----------------------------------------------------------------------------------------------- 18
//----------------------------------------------------------------------------------------------- 18
/*
TEST_CASE ( "TP3_Etudiant::Constructeur" ) {
TEST_CASE
(
"TP3_Etudiant::Constructeur"
)
{
const
double
a
=
12.0
;
const
double
a
=
12.0
;
const
char
*
n
=
"Machin"
;
const
char
*
n
=
"Machin"
;
...
@@ -316,19 +316,19 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
...
@@ -316,19 +316,19 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
REQUIRE
(
v
.
getNote
()
==
Approx
(
a
)
);
REQUIRE
(
v
.
getNote
()
==
Approx
(
a
)
);
REQUIRE
(
v
.
getEtudiant
().
c_str
()
!=
0
);
REQUIRE
(
v
.
getEtudiant
().
c_str
()
!=
0
);
REQUIRE
(
v
.
getEtudiant
()
==
n
);
REQUIRE
(
v
.
getEtudiant
()
==
n
);
}
*/
}
//----------------------------------------------------------------------------------------------- 19
//----------------------------------------------------------------------------------------------- 19
/*
TEST_CASE ( "TP3_Etudiant::ConstructeurDefaut" ) {
TEST_CASE
(
"TP3_Etudiant::ConstructeurDefaut"
)
{
Valeur
v
;
Valeur
v
;
REQUIRE
(
v
.
getNombre
()
==
Approx
(
0.0
)
);
REQUIRE
(
v
.
getNombre
()
==
Approx
(
0.0
)
);
REQUIRE
(
v
.
getNote
()
==
Approx
(
0.0
)
);
REQUIRE
(
v
.
getNote
()
==
Approx
(
0.0
)
);
REQUIRE
(
v
.
getEtudiant
()
==
"inconnu"
);
REQUIRE
(
v
.
getEtudiant
()
==
"inconnu"
);
}
*/
}
//----------------------------------------------------------------------------------------------- 20
//----------------------------------------------------------------------------------------------- 20
/*
TEST_CASE ( "TP3_Etudiant::Accesseurs" ) {
TEST_CASE
(
"TP3_Etudiant::Accesseurs"
)
{
const
double
a
=
12.0
;
const
double
a
=
12.0
;
const
char
*
n
=
"Machin"
;
const
char
*
n
=
"Machin"
;
...
@@ -340,19 +340,19 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
...
@@ -340,19 +340,19 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
REQUIRE
(
v
.
getNombre
()
==
Approx
(
a
)
);
REQUIRE
(
v
.
getNombre
()
==
Approx
(
a
)
);
REQUIRE
(
v
.
getNote
()
==
Approx
(
a
)
);
REQUIRE
(
v
.
getNote
()
==
Approx
(
a
)
);
REQUIRE
(
v
.
getEtudiant
()
==
n
);
REQUIRE
(
v
.
getEtudiant
()
==
n
);
}
*/
}
//----------------------------------------------------------------------------------------------- 21
//----------------------------------------------------------------------------------------------- 21
/*
TEST_CASE ( "TP3_Etudiant::AccesseursConstants" ) {
TEST_CASE
(
"TP3_Etudiant::AccesseursConstants"
)
{
const
Valeur
v
;
const
Valeur
v
;
REQUIRE
(
v
.
getNombre
()
==
Approx
(
0.0
)
);
REQUIRE
(
v
.
getNombre
()
==
Approx
(
0.0
)
);
REQUIRE
(
v
.
getNote
()
==
Approx
(
0.0
)
);
REQUIRE
(
v
.
getNote
()
==
Approx
(
0.0
)
);
REQUIRE
(
v
.
getEtudiant
()
==
"inconnu"
);
REQUIRE
(
v
.
getEtudiant
()
==
"inconnu"
);
}
*/
}
//----------------------------------------------------------------------------------------------- 22
//----------------------------------------------------------------------------------------------- 22
/*
TEST_CASE ( "TP3_Valeurs::Association" ) {
TEST_CASE
(
"TP3_Valeurs::Association"
)
{
using
histo_t
=
Histogramme
<>
;
using
histo_t
=
Histogramme
<>
;
double
v
[]
=
{
7.0
,
9.0
,
8.0
,
5.0
,
10.0
,
14.0
,
13.0
,
6.0
,
5.5
,
13.5
};
double
v
[]
=
{
7.0
,
9.0
,
8.0
,
5.0
,
10.0
,
14.0
,
13.0
,
6.0
,
5.5
,
13.5
};
...
@@ -376,10 +376,10 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
...
@@ -376,10 +376,10 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
REQUIRE
(
p
.
second
.
getNote
()
==
Approx
(
notes
[
i
])
);
REQUIRE
(
p
.
second
.
getNote
()
==
Approx
(
notes
[
i
])
);
++
i
;
++
i
;
}
}
}
*/
}
//----------------------------------------------------------------------------------------------- 23
//----------------------------------------------------------------------------------------------- 23
/*
TEST_CASE ( "TP3_Valeurs::Intervalle" ) {
TEST_CASE
(
"TP3_Valeurs::Intervalle"
)
{
using
histo_t
=
Histogramme
<>
;
using
histo_t
=
Histogramme
<>
;
double
v
[]
=
{
7.0
,
9.0
,
8.0
,
5.0
,
10.0
,
14.0
,
13.0
,
6.0
,
5.5
,
13.5
};
double
v
[]
=
{
7.0
,
9.0
,
8.0
,
5.0
,
10.0
,
14.0
,
13.0
,
6.0
,
5.5
,
13.5
};
...
@@ -402,10 +402,8 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
...
@@ -402,10 +402,8 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
for
(
const
Classe
&
c
:
h
.
getClasses
())
{
for
(
const
Classe
&
c
:
h
.
getClasses
())
{
auto
interval
=
h
.
getValeurs
(
c
);
auto
interval
=
h
.
getValeurs
(
c
);
int
j
=
0
;
int
j
=
0
;
while
(
interval
.
first
!=
interval
.
second
)
{
while
(
interval
.
first
!=
interval
.
second
)
{
REQUIRE
(
(
interval
.
first
)
->
second
.
getNote
()
==
Approx
(
notes
[
i
][
j
])
);
REQUIRE
(
(
interval
.
first
)
->
second
.
getNote
()
==
Approx
(
notes
[
i
][
j
])
);
++
(
interval
.
first
);
++
(
interval
.
first
);
++
j
;
++
j
;
}
}
...
@@ -414,6 +412,6 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
...
@@ -414,6 +412,6 @@ TEST_CASE ( "TP3_Histogramme::Conversion" ) {
++
i
;
++
i
;
}
}
}
*/
}
// Fin //-------------------------------------------------------------------------------------------
// Fin //-------------------------------------------------------------------------------------------
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
sign in
to comment