Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions src/main/java/micromaniac/micromaniac/Emploie/Emploie.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package micromaniac.micromaniac.Emploie;

import java.util.HashMap;
import java.util.Map;

public class Emploie {

private int nbEmploie;
private int charge;
private HashMap<String, Integer> tabEmploie;

public Emploie(int nbEmploie, int charge, HashMap<String, Integer> tabEmploie){

public Emploie(int nbEmploie){
this.nbEmploie= nbEmploie;
this.charge= charge;
this.tabEmploie= tabEmploie;
}

public int getNbEmploie() {
Expand All @@ -16,16 +24,34 @@ public void setNbEmploie(int nbEmploie) {
this.nbEmploie = nbEmploie;
}

public int getCharge() {
return charge;
}

public void setCharge(int charge) {
this.charge = charge;
}

public HashMap<String, Integer> getTabEmploie() {
return tabEmploie;
}

public void setTabEmploie(HashMap<String, Integer> tabEmploie) {
this.tabEmploie = tabEmploie;
}

// embauche un employer et on paye des charges
public int embauche(int argent) {
public int embauche() {
if (this.nbEmploie <= 5) {
setNbEmploie(this.nbEmploie + 1);
argent=argent-500;
this.charge+=500;
System.out.print("vous avez un nouvel employé");

HashMap<String, Integer> nouveauMap = new HashMap<>(getTabEmploie());
nouveauMap.put("E"+ String.valueOf(this.nbEmploie),0);
setTabEmploie(nouveauMap);
} else {
System.out.print("vous avez déja assez d'employé, acheter un nouveau magasin");
}
return argent;
return this.charge;
}
}
20 changes: 17 additions & 3 deletions src/main/java/micromaniac/micromaniac/Magasin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import micromaniac.micromaniac.Stock.Neuf;
import micromaniac.micromaniac.Stock.Occasion;


import java.util.*;


Expand All @@ -22,7 +21,10 @@ public class Magasin implements Reduction{
private String[] devanture;
private int employe;

Emploie e = new Emploie(1);
Emploie e = new Emploie(1,500, new HashMap<>(Map.of(
"E1", 0

)));
Panier client = new Panier(new String[]{ " ", " ", " ", " ", " "});
Neuf n = new Neuf(
1,
Expand Down Expand Up @@ -180,6 +182,18 @@ public void accueil() {
this.rachatPossible = true;
client.choixPanier(this.devanture, client.getPanier());
System.out.println("Bien le bonjour");

for (int i = 1; i <= e.getNbEmploie() ; i++) {
System.out.println("truc");
HashMap<String, Integer> nouveauMap = new HashMap<>(e.getTabEmploie());
nouveauMap.put("E"+ String.valueOf(i),e.getTabEmploie().get("E"+ String.valueOf(i))+1);
e.setTabEmploie(nouveauMap);
System.out.println("truc");
if (e.getTabEmploie().get("E"+ String.valueOf(i))==30){
this.argent-=e.getCharge();
System.out.println("truc");
}
}
} else {
System.out.println("Il y a déjà un client qui attend son tour");
}
Expand Down Expand Up @@ -394,7 +408,7 @@ public void ajout(String jeu, boolean retro) {

//permet d'ajouté un employer et donc de gerer plus de stock
public void nouvelEmployer(){
e.embauche(this.argent);
e.embauche();
n.setStokeLevel(e.getNbEmploie());
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/micromaniac/micromaniac/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private Node createGestionPage() {
});

embauche.setOnAction(e -> {
int argent = magasin.e.embauche(magasin.getArgent());
int argent = magasin.e.embauche();
magasin.setArgent(argent);
magasin.n.setStokeLevel(magasin.e.getNbEmploie());
refreshAll();
Expand Down