diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
index 176efbc..e2445b0 100644
--- a/.idea/deploymentTargetSelector.xml
+++ b/.idea/deploymentTargetSelector.xml
@@ -13,6 +13,9 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 74dd639..53f59de 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,11 @@
+
+
+
+
+
diff --git a/app/src/androidTest/java/com/example/coach/view/MainActivityTest.java b/app/src/androidTest/java/com/example/coach/view/MainActivityTest.java
new file mode 100644
index 0000000..f832232
--- /dev/null
+++ b/app/src/androidTest/java/com/example/coach/view/MainActivityTest.java
@@ -0,0 +1,39 @@
+package com.example.coach.view;
+
+import androidx.test.ext.junit.rules.ActivityScenarioRule;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static androidx.test.espresso.Espresso.onView;
+import static androidx.test.espresso.action.ViewActions.click;
+import static androidx.test.espresso.action.ViewActions.typeText;
+import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
+import static androidx.test.espresso.matcher.ViewMatchers.withId;
+import static androidx.test.espresso.assertion.ViewAssertions.matches;
+import static androidx.test.espresso.matcher.ViewMatchers.withText;
+
+import com.example.coach.R;
+
+@RunWith(AndroidJUnit4.class)
+public class MainActivityTest {
+ @Rule
+ public ActivityScenarioRule activityRule = new ActivityScenarioRule<>(MainActivity.class);
+
+ @Test
+ public void testCalculIMG(){
+ onView(withId(R.id.txtPoids)).perform(typeText("70"), closeSoftKeyboard());
+ onView(withId(R.id.txtTaille)).perform(typeText("180"), closeSoftKeyboard());
+ onView(withId(R.id.txtAge)).perform(typeText("40"), closeSoftKeyboard());
+
+ onView(withId(R.id.btnCalc)).perform(click());
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/coach/contract/ICalculView.java b/app/src/main/java/com/example/coach/contract/ICalculView.java
index 3653bce..d9a992f 100644
--- a/app/src/main/java/com/example/coach/contract/ICalculView.java
+++ b/app/src/main/java/com/example/coach/contract/ICalculView.java
@@ -1,5 +1,15 @@
package com.example.coach.contract;
+/**
+ * Contrat pour que le CalculPresenter puisse envoyer des infos à la vue
+ */
public interface ICalculView {
+ /**
+ * Méthode permettant le transfert des résultats vers la vue
+ * @param image nom du fichier du smiley
+ * @param img valeur de l'img calculé
+ * @param message message à afficher
+ * @param normal vrai si l'img est normal
+ */
void AfficherResultat(String image, double img, String message, boolean normal);
}
diff --git a/app/src/main/java/com/example/coach/model/Profil.java b/app/src/main/java/com/example/coach/model/Profil.java
index aea1cc2..3664a36 100644
--- a/app/src/main/java/com/example/coach/model/Profil.java
+++ b/app/src/main/java/com/example/coach/model/Profil.java
@@ -1,5 +1,8 @@
package com.example.coach.model;
+/**
+ * Classe métier contenant les informations d'un profil
+ */
public class Profil {
private static final int MIN_FEMME = 25;
private static final int MAX_FEMME = 30;
@@ -16,6 +19,13 @@ public class Profil {
private double img;
private int indice;
+ /**
+ * Constructeur : Valorise les propriétés
+ * @param poids
+ * @param taille
+ * @param age
+ * @param sexe
+ */
public Profil(Integer poids, Integer taille, Integer age, Integer sexe) {
this.poids = poids;
this.taille = taille;
@@ -25,6 +35,10 @@ public class Profil {
this.indice = calculIndice();
}
+ /**
+ * Calcul de l'img
+ * @return résultat du calcul de l'img
+ */
private double calculImg()
{
double img;
@@ -33,6 +47,11 @@ public class Profil {
return img;
}
+ /**
+ * Calcul de l'indice correspondant à l'img
+ * pour afficher le bon message et la bonne image
+ * @return valeur de l'indice
+ */
private int calculIndice()
{
int min;
@@ -55,15 +74,34 @@ public class Profil {
}
}
+ /**
+ *
+ * @return Valeur de l'img
+ */
public double getImg(){
return this.img;
}
+
+ /**
+ *
+ * @return message à afficher selon l'img
+ */
public String getMessage(){
return MESSAGE[this.indice];
}
+
+ /**
+ * nom de l'image drawable à afficher
+ * @return
+ */
public String getImage(){
return IMAGE[this.indice];
}
+
+ /**
+ *
+ * @return vrai si l'img est normal
+ */
public boolean normal(){
if(indice == 1){
return true;
diff --git a/app/src/main/java/com/example/coach/presenter/CalculPresenter.java b/app/src/main/java/com/example/coach/presenter/CalculPresenter.java
index 7c04730..d801099 100644
--- a/app/src/main/java/com/example/coach/presenter/CalculPresenter.java
+++ b/app/src/main/java/com/example/coach/presenter/CalculPresenter.java
@@ -3,13 +3,28 @@ package com.example.coach.presenter;
import com.example.coach.contract.ICalculView;
import com.example.coach.model.Profil;
+/**
+ * 'presenter' dédié à la vue affichant le calcul de l'img
+ */
public class CalculPresenter {
private ICalculView vue;
+ /**
+ * Constructeur : valorise la propriété permettant d'accéder à la vue
+ * @param vue
+ */
public CalculPresenter(ICalculView vue) {
this.vue = vue;
}
+ /**
+ * Créer le profil avec les informations reçues de la vue
+ * Renvoie à la vue les infos à afficher
+ * @param sexe
+ * @param poids
+ * @param taille
+ * @param age
+ */
public void creerProfil(Integer sexe, Integer poids, Integer taille, Integer age)
{
Profil profil = new Profil(poids, taille, age, sexe);
diff --git a/app/src/main/java/com/example/coach/view/MainActivity.java b/app/src/main/java/com/example/coach/view/MainActivity.java
index 4970d36..4fa7628 100644
--- a/app/src/main/java/com/example/coach/view/MainActivity.java
+++ b/app/src/main/java/com/example/coach/view/MainActivity.java
@@ -19,6 +19,9 @@ import com.example.coach.R;
import com.example.coach.contract.ICalculView;
import com.example.coach.presenter.CalculPresenter;
+/**
+ * Activity qui permet le calcul de l'img
+ */
public class MainActivity extends AppCompatActivity implements ICalculView {
private EditText txtPoids;
@@ -45,6 +48,13 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
init();
}
+ /**
+ * Méthode permettant l'affichage du résultat du calcul de l'img
+ * @param image nom du fichier drawable pour le smiley
+ * @param img valeur de l'img
+ * @param message message à afficher
+ * @param normal faux si l'img n'est pas normal, vrai dans le cas inverse
+ */
@Override
public void AfficherResultat(String image, double img, String message, boolean normal) {
int iamgeId = getResources().getIdentifier(image, "drawable", getPackageName());
@@ -63,6 +73,9 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
}
}
+ /**
+ * Traitements à réaliser lors du lancement de l'application
+ */
private void init()
{
chargeObjetsGraphiques();
@@ -70,6 +83,9 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
btnCalc.setOnClickListener(v -> btnCalcClic());
}
+ /**
+ * Récupère les objets graphiques
+ */
private void chargeObjetsGraphiques()
{
txtPoids = (EditText) findViewById(R.id.txtPoids);
@@ -86,6 +102,9 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
btnCalc = (Button) findViewById(R.id.btnCalc);
}
+ /**
+ * Traitements à réaliser lors du clic sur le bouton
+ */
private void btnCalcClic()
{
int poids = 0, taille = 0, age = 0, sexe = 0;