TP iostream
This commit is contained in:
BIN
DEV2.1/hasard/exo3/ObjetAleatoire.class
Normal file
BIN
DEV2.1/hasard/exo3/ObjetAleatoire.class
Normal file
Binary file not shown.
5
DEV2.1/hasard/exo3/ObjetAleatoire.java
Normal file
5
DEV2.1/hasard/exo3/ObjetAleatoire.java
Normal file
@@ -0,0 +1,5 @@
|
||||
public interface ObjetAleatoire
|
||||
{
|
||||
void lancer();
|
||||
int lire();
|
||||
}
|
||||
BIN
DEV2.1/hasard/exo3/Piece.class
Normal file
BIN
DEV2.1/hasard/exo3/Piece.class
Normal file
Binary file not shown.
25
DEV2.1/hasard/exo3/Piece.java
Normal file
25
DEV2.1/hasard/exo3/Piece.java
Normal file
@@ -0,0 +1,25 @@
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class Piece implements ObjetAleatoire
|
||||
{
|
||||
Random rnd = new Random(System.currentTimeMillis());
|
||||
|
||||
private int pof;
|
||||
|
||||
public void lancer()
|
||||
{
|
||||
this.pof = rnd.nextInt(2);
|
||||
}
|
||||
|
||||
public int lire()
|
||||
{
|
||||
return this.pof;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Piece test = new Piece();
|
||||
test.lancer();
|
||||
System.out.println(test.lire());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user