package pack8;
public class BanditMachot {
static Roue [] tab;
static int gain;
public BanditMachot()
{
Roue [] tab =new Roue [4];
}
public static int joue()
{
//declaration variables
int[] numberofoccurance=new int [4];
int [] elements=new int[4];
int forElements=0;
boolean trouve;
int j=0;
gain=0;
//traitement
numberofoccurance[0]=1;
elements[0]=tab[0].get();
for (int i=1;i<4;i++)
{
trouve=false;
j=0;
while((j<i)&&(trouve==false))
{
if((tab[i].get()==elements[j]))
{
trouve=true;
numberofoccurance[i]+=1;
}
else
{
j=j+1;
}
if(trouve==false)
{
forElements=forElements+1;
elements[forElements]=tab[i].get();
numberofoccurance[forElements]+=1;
}
}
}
for(int c=0;c<forElements;c++)
{
if(numberofoccurance[c]==2)
{
gain=10;
}
else
if(numberofoccurance[c]==3)
{
gain=100;
}
else
if(numberofoccurance[c]==4)
{
gain=1000;
}
else
{
gain=0;
}
}
return gain;
}
}
package pack8;
public class TestBanditMachot {
public static void main(String[] args) {
// TODO Auto-generated method stub
BanditMachot bm=new BanditMachot();
BanditMachot.joue();
}
}
package pack8;
public class Roue {
int aleatoire;
public void lance()
{
aleatoire= 0 + (int)(Math.random() * ((4 - 0) + 1));
}
public int get()
{
return this.aleatoire;
}
}
je pense que il y'a des fautes que je ne comprends pas (((
- Edité par Anonyme 9 décembre 2018 à 19:07:06
Bandit machot ne fonctionne pas
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.