S3a : préparation pour la persistance
This commit is contained in:
parent
00b7ac3fda
commit
102a28da49
7 changed files with 105 additions and 7 deletions
|
|
@ -4,14 +4,27 @@
|
|||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<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">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=QGP7K78LKBMVZTRC" />
|
||||
</handle>
|
||||
</Target>
|
||||
</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 runConfigName="testCalculIMG()">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
|
|
|
|||
|
|
@ -37,4 +37,5 @@ dependencies {
|
|||
testImplementation libs.junit
|
||||
androidTestImplementation libs.ext.junit
|
||||
androidTestImplementation libs.espresso.core
|
||||
implementation 'com.google.code.gson:gson:2.11.0'
|
||||
}
|
||||
|
|
@ -12,4 +12,13 @@ public interface ICalculView {
|
|||
* @param normal vrai si l'img est 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.example.coach.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Classe métier contenant les informations d'un profil
|
||||
*/
|
||||
|
|
@ -18,6 +20,7 @@ public class Profil {
|
|||
private Integer sexe;
|
||||
private double img;
|
||||
private int indice;
|
||||
private Date dateMesure;
|
||||
|
||||
/**
|
||||
* Constructeur : Valorise les propriétés
|
||||
|
|
@ -26,13 +29,14 @@ public class Profil {
|
|||
* @param age
|
||||
* @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.taille = taille;
|
||||
this.age = age;
|
||||
this.sexe = sexe;
|
||||
this.img = calculImg();
|
||||
this.indice = calculIndice();
|
||||
this.dateMesure = dateMesure;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,4 +113,52 @@ public class Profil {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.example.coach.presenter;
|
|||
import com.example.coach.contract.ICalculView;
|
||||
import com.example.coach.model.Profil;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* '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)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@ import static org.junit.Assert.*;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ProfilTest {
|
||||
|
||||
private Profil profilMaigre = new Profil (45, 170, 20, 0);
|
||||
private Profil profilNormal = new Profil (70, 180, 40, 1);
|
||||
private Profil profilGras = new Profil (67, 165, 35, 0);
|
||||
private Profil profilMaigre = new Profil (45, 170, 20, 0, new Date());
|
||||
private Profil profilNormal = new Profil (70, 180, 40, 1, new Date());
|
||||
private Profil profilGras = new Profil (67, 165, 35, 0, new Date());
|
||||
|
||||
@Test
|
||||
public void getImg() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue