27 Avril
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice1/MainExo1.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice1/MainExo1.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										35
									
								
								ControleMachineJava/Exercice1/MainExo1.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								ControleMachineJava/Exercice1/MainExo1.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import javax.swing.*;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
public class MainExo1 {
 | 
			
		||||
 | 
			
		||||
	public static void main(String[] args) {
 | 
			
		||||
		for(int j=0; j<args.length; j++){
 | 
			
		||||
			if (args.length==0 || Integer.parseInt(args[j])<=0){
 | 
			
		||||
				System.out.println("Donner un entier strictement positif en argument.");
 | 
			
		||||
			}else{
 | 
			
		||||
				int x = Integer.parseInt(args[j]);
 | 
			
		||||
				int[] diviseur = new int[1];
 | 
			
		||||
				boolean estPremier = true;
 | 
			
		||||
				int indice=0;
 | 
			
		||||
				for (int i=2; i<x; i++){
 | 
			
		||||
					if(x % i == 0){
 | 
			
		||||
						estPremier = false;
 | 
			
		||||
						diviseur=Arrays.copyOf(diviseur,indice+1);
 | 
			
		||||
						diviseur[indice]=i;
 | 
			
		||||
						indice++;
 | 
			
		||||
					}
 | 
			
		||||
				} if (estPremier==true){
 | 
			
		||||
					System.out.println("L'entier "+x+" est premier.");
 | 
			
		||||
				}else{
 | 
			
		||||
					System.out.println("L'entier "+x+" n'est pas premier.");
 | 
			
		||||
					System.out.println("Les diviseurs de "+x+" sont 1 et lui-meme ainsi que:");
 | 
			
		||||
					for (int i=0; i<diviseur.length; i++) {
 | 
			
		||||
						System.out.println(diviseur[i]);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								ControleMachineJava/Exercice2/Entiexte.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								ControleMachineJava/Exercice2/Entiexte.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import javax.swing.*;
 | 
			
		||||
import java.lang.*;
 | 
			
		||||
 | 
			
		||||
public class Entiexte {
 | 
			
		||||
	private String entier;
 | 
			
		||||
	public Entiexte(String nombre) {
 | 
			
		||||
		this.entier=nombre;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Entiexte(int x) {
 | 
			
		||||
		this.entier=x;
 | 
			
		||||
	}
 | 
			
		||||
							
								
								
									
										0
									
								
								ControleMachineJava/Exercice2/MainExo2.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								ControleMachineJava/Exercice2/MainExo2.java
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice3/MainExo3.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice3/MainExo3.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										52
									
								
								ControleMachineJava/Exercice3/MainExo3.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								ControleMachineJava/Exercice3/MainExo3.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import javax.swing.*;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
public class MainExo3 {
 | 
			
		||||
 | 
			
		||||
	public static ObjetAleatoire genererOA(){
 | 
			
		||||
		ObjetAleatoire p;
 | 
			
		||||
		Random r = new Random();
 | 
			
		||||
		if((r.nextInt()%2)==0){
 | 
			
		||||
			p = new Piece();
 | 
			
		||||
		}else{
 | 
			
		||||
			p = new PiecePipee();
 | 
			
		||||
		} return p;
 | 
			
		||||
	} 
 | 
			
		||||
 | 
			
		||||
	public static void main(String[] args) {
 | 
			
		||||
		ObjetAleatoire o;
 | 
			
		||||
		int f;
 | 
			
		||||
		int nbrf=0;
 | 
			
		||||
		int nbrp=0;
 | 
			
		||||
		int truquer=0;
 | 
			
		||||
		o=genererOA();
 | 
			
		||||
		o.lancer();
 | 
			
		||||
		f=o.lire();
 | 
			
		||||
		if(f==1||f==-1){
 | 
			
		||||
			System.out.println("Vous avez fait face.");
 | 
			
		||||
		}else{
 | 
			
		||||
			System.out.println("Vous avez fait pile.");
 | 
			
		||||
		} for(int j=0; j<10 ;j++){
 | 
			
		||||
			nbrf=0;
 | 
			
		||||
			nbrp=0;
 | 
			
		||||
			for(int i=0;i<100;i++){
 | 
			
		||||
				o.lancer();
 | 
			
		||||
				f=o.lire();
 | 
			
		||||
				if(f==1||f==-1){
 | 
			
		||||
					nbrf++;
 | 
			
		||||
				}else{
 | 
			
		||||
					nbrp++;
 | 
			
		||||
				}
 | 
			
		||||
			} if (nbrp<=nbrf){
 | 
			
		||||
				truquer++;
 | 
			
		||||
			}else{
 | 
			
		||||
				truquer--;
 | 
			
		||||
			}
 | 
			
		||||
		} if (truquer>=-7){
 | 
			
		||||
			System.out.println("Piece non truquer");
 | 
			
		||||
		}else{
 | 
			
		||||
			System.out.println("Piece truquer");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice3/ObjetAleatoire.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice3/ObjetAleatoire.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										4
									
								
								ControleMachineJava/Exercice3/ObjetAleatoire.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								ControleMachineJava/Exercice3/ObjetAleatoire.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
public interface ObjetAleatoire{
 | 
			
		||||
	void lancer();
 | 
			
		||||
	int lire();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice3/Piece.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice3/Piece.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										21
									
								
								ControleMachineJava/Exercice3/Piece.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								ControleMachineJava/Exercice3/Piece.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import javax.swing.*;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
public class Piece implements ObjetAleatoire {
 | 
			
		||||
 | 
			
		||||
	private int faceVisible; // 0 = pile;  1 = face.
 | 
			
		||||
 | 
			
		||||
	public Piece(){
 | 
			
		||||
		this.faceVisible=faceVisible;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void lancer(){
 | 
			
		||||
		Random r = new Random();
 | 
			
		||||
		this.faceVisible=(r.nextInt()%2);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public int lire(){
 | 
			
		||||
		return faceVisible;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice3/PiecePipee.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ControleMachineJava/Exercice3/PiecePipee.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										25
									
								
								ControleMachineJava/Exercice3/PiecePipee.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								ControleMachineJava/Exercice3/PiecePipee.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import javax.swing.*;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
public class PiecePipee implements ObjetAleatoire {
 | 
			
		||||
 | 
			
		||||
	private int faceVisible; // 0 = pile;  1 = face.
 | 
			
		||||
 | 
			
		||||
	public PiecePipee(){
 | 
			
		||||
		this.faceVisible=faceVisible;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void lancer(){
 | 
			
		||||
		Random r = new Random();
 | 
			
		||||
		if(r.nextInt()%10<7&&r.nextInt()%10>-7){
 | 
			
		||||
			this.faceVisible=0;
 | 
			
		||||
		}else{
 | 
			
		||||
			this.faceVisible=1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public int lire(){
 | 
			
		||||
		return faceVisible;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								ControleMachineJava/reponses.tar
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ControleMachineJava/reponses.tar
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user