S3a : préparation pour la persistance

This commit is contained in:
Erwann PHILIPPE 2026-02-03 16:14:51 +01:00
parent 00b7ac3fda
commit 102a28da49
7 changed files with 105 additions and 7 deletions

View file

@ -4,14 +4,27 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2026-02-03T12:06:28.141777700Z"> <DropdownSelection timestamp="2026-02-03T14:43:08.366675Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=QGP7K78LKBMVZTRC" /> <DeviceId pluginId="PhysicalDevice" identifier="serial=QGP7K78LKBMVZTRC" />
</handle> </handle>
</Target> </Target>
</DropdownSelection> </DropdownSelection>
<DialogSelection /> <DialogSelection>
<targets>
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=QGP7K78LKBMVZTRC" />
</handle>
</Target>
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\erwan\.android\avd\Medium_Phone.avd" />
</handle>
</Target>
</targets>
</DialogSelection>
</SelectionState> </SelectionState>
<SelectionState runConfigName="testCalculIMG()"> <SelectionState runConfigName="testCalculIMG()">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />

View file

@ -37,4 +37,5 @@ dependencies {
testImplementation libs.junit testImplementation libs.junit
androidTestImplementation libs.ext.junit androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core androidTestImplementation libs.espresso.core
implementation 'com.google.code.gson:gson:2.11.0'
} }

View file

@ -12,4 +12,13 @@ public interface ICalculView {
* @param normal vrai si l'img est normal * @param normal vrai si l'img est normal
*/ */
void AfficherResultat(String image, double img, String message, boolean normal); void AfficherResultat(String image, double img, String message, boolean normal);
/**
* Méthode permettant le transferts des données stockées vers la vue
* @param poids poids stocké
* @param taille taille stockée
* @param age âge stocké
* @param sexe sexe stocké
*/
void remplirChamps(Integer poids, Integer taille, Integer age, Integer sexe);
} }

View file

@ -1,5 +1,7 @@
package com.example.coach.model; package com.example.coach.model;
import java.util.Date;
/** /**
* Classe métier contenant les informations d'un profil * Classe métier contenant les informations d'un profil
*/ */
@ -18,6 +20,7 @@ public class Profil {
private Integer sexe; private Integer sexe;
private double img; private double img;
private int indice; private int indice;
private Date dateMesure;
/** /**
* Constructeur : Valorise les propriétés * Constructeur : Valorise les propriétés
@ -26,13 +29,14 @@ public class Profil {
* @param age * @param age
* @param sexe * @param sexe
*/ */
public Profil(Integer poids, Integer taille, Integer age, Integer sexe) { public Profil(Integer poids, Integer taille, Integer age, Integer sexe, Date dateMesure) {
this.poids = poids; this.poids = poids;
this.taille = taille; this.taille = taille;
this.age = age; this.age = age;
this.sexe = sexe; this.sexe = sexe;
this.img = calculImg(); this.img = calculImg();
this.indice = calculIndice(); this.indice = calculIndice();
this.dateMesure = dateMesure;
} }
/** /**
@ -109,4 +113,52 @@ public class Profil {
return false; return false;
} }
} }
/**
*
* @return poids de la personne
*/
public Integer getPoids() {
return poids;
}
/**
*
* @return taille de la personne
*/
public Integer getTaille() {
return taille;
}
/**
*
* @return âge de la personne
*/
public Integer getAge() {
return age;
}
/**
*
* @return sexe de la personne
*/
public Integer getSexe() {
return sexe;
}
/**
*
* @return Date de la mesure
*/
public Date getDateMesure() {
return dateMesure;
}
/**
*
* @param dateMesure Date de la mesure
*/
public void setDateMesure(Date dateMesure) {
this.dateMesure = dateMesure;
}
} }

View file

@ -3,6 +3,8 @@ package com.example.coach.presenter;
import com.example.coach.contract.ICalculView; import com.example.coach.contract.ICalculView;
import com.example.coach.model.Profil; import com.example.coach.model.Profil;
import java.util.Date;
/** /**
* 'presenter' dédié à la vue affichant le calcul de l'img * 'presenter' dédié à la vue affichant le calcul de l'img
*/ */
@ -27,7 +29,7 @@ public class CalculPresenter {
*/ */
public void creerProfil(Integer sexe, Integer poids, Integer taille, Integer age) public void creerProfil(Integer sexe, Integer poids, Integer taille, Integer age)
{ {
Profil profil = new Profil(poids, taille, age, sexe); Profil profil = new Profil(poids, taille, age, sexe, new Date());
vue.AfficherResultat(profil.getImage(), profil.getImg(), profil.getMessage(), profil.normal()); vue.AfficherResultat(profil.getImage(), profil.getImg(), profil.getMessage(), profil.normal());
} }
} }

View file

@ -73,6 +73,25 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
} }
} }
/**
* @param poids poids stocké
* @param taille taille stockée
* @param age âge stocké
* @param sexe sexe stocké
*/
@Override
public void remplirChamps(Integer poids, Integer taille, Integer age, Integer sexe) {
txtPoids.setText(poids.toString());
txtTaille.setText(taille.toString());
txtAge.setText(age.toString());
if(sexe == 1){
rdHomme.setChecked(true);
}else{
rdFemme.setChecked(false);
}
}
/** /**
* Traitements à réaliser lors du lancement de l'application * Traitements à réaliser lors du lancement de l'application
*/ */

View file

@ -4,11 +4,13 @@ import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import java.util.Date;
public class ProfilTest { public class ProfilTest {
private Profil profilMaigre = new Profil (45, 170, 20, 0); private Profil profilMaigre = new Profil (45, 170, 20, 0, new Date());
private Profil profilNormal = new Profil (70, 180, 40, 1); private Profil profilNormal = new Profil (70, 180, 40, 1, new Date());
private Profil profilGras = new Profil (67, 165, 35, 0); private Profil profilGras = new Profil (67, 165, 35, 0, new Date());
@Test @Test
public void getImg() { public void getImg() {