1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
| public class Registre {
private int taille ;
private byte [] tab ;
/**
* Constructeur Vide
*/
public Registre (){
}
public Registre(int taille){
this.taille = taille ;
}
/**
*
* @param tab
*/
public Registre(byte[] tab){
this.tab = tab ;
}
/**
*
* @param r
*/
public Registre(Registre r){
this.taille = r.taille ;
this.tab = r.tab ;
}
public Registre and (Registre r ){
Registre r_res = new Registre();
for(int i = 0; i < tab.length ; i++){
if ( (this.tab[i]== 0 && r.tab[i]==0 ) || (this.tab[i]== 0 && r.tab[i] == 1) ||
(this.tab[i]== 1 && r.tab[i] == 0) ){
r_res.tab[i] = 0;
}
else
r_res.tab[i] = 1;
}
return r_res ;
}
public void decaleDroite(){
byte y = this.tab[tab.length];
for(int i = 0; i <tab.length -1 ; i++){
this.tab[i + 1] = this.tab[i];
}
this.tab[0]= y ;
}
public void decaleGauche(){
byte x = this.tab[0];
for(int i = 0; i <tab.length -1 ; i++){
this.tab[i ] = this.tab[i+1];
}
this.tab[0]= x ;
}
public void init(){
System.out.println("Initialiser le registre courant !");
this.taille = Clavier.readInt("entrer la taille du registre");
System.out.println("initialiser le registre");
for(int i =0; i< taille ; i++){
this.tab[i] = Clavier.readByte("valeur num :" + i);
System.out.println();
}
}
/*
public int[] getTab(){
}
public Registre ou (Registre r){
}
public int registreToDec(){
}
public String registreToHexa(){
}
public void setTab(byte []t){
}
public int tailleRegistre(){
}
*/
public String toString(){
String s ;
s = "le registre est : " + this.tab +" et sa taille et de "+ this.taille;
return s ;
}
} |