Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

please explain this code for me in some comentary

LUKAS29LUKAS29 ClujMember Posts: 1

import java.util.*;
public class Pachet{
int numaratoare=0;
int pachet[][] =new int [5][16];
Random aleator =new Random();
public int getCuloare()
{
return this.aleator.nextInt(4)+1;//random between 1 and 4 inclusiv
}
public int getRang()
{
return this.aleator.nextInt(13)+2;//random between 1 and 15 inclusiv
}
public int[] extragecarte()
{
int culoare=this.getCuloare();
int rang=this.getRang();
if( this.numaratoare < 52 )
{
while(this.pachet[culoare][rang]==1)
{
culoare=this.getCuloare();
rang=this.getRang();
}
this.pachet[culoare][rang]=1;
this.numaratoare++;
}
int[] carte=new int[2];
carte[0]=culoare;
carte[1]=rang;
return carte;
}
}

public class Main{
public static void main(String[] args) {
Pachet pachet=new Pachet();
for(int i=1;i<=17;i++)
{
int [] carte1=pachet.extragecarte();
int [] carte2=pachet.extragecarte();
int [] carte3=pachet.extragecarte();
/////verificare 3 carti crescatoare
//System.out.println("Carti in ordine crescatoare dupa rang:");
if(carte1[1]<carte2[1] && carte2[1]<carte3[1])
{
System.out.println("3 carti in ordine crescatoare: "+carte1[0]+"."+carte1[1]+"~"+carte2[0]+"."+carte2[1]+"~"+carte3[0]+"."+carte3[1]);
}
else
{
System.out.println("-N-");

Sign In or Register to comment.