hey guys i did some code to do hamming and I have a syntax error in my code and I need to correct it and I don't know how to resolved this is my code
import java.lang.Math;
char [] GenerateSequence(int length)
int[] numbers = new int[legnth];
for (int i = 0; i < numbers.length; i++) {
if (Math.random() > 0.5) {
numbers[i] = 1;
else
numbers[i] = 0;
}
return numbers;
}
}
char CalculateNbControlBits(int length){
int nextpower2=1;
int p=1;
Nombredebit=0;
for (int i = 0; i < numbers.length; i++) {
{
if(p == nextpower2)
{
Nombredebit++;
nextpower2 = nextpower2 * 2;
}
p++;
}
return Nombredebit;
}
}
void AddControlBits(char info[], int length, int nbControlBits)
{
for (int i = 0; (i < numbers.length()); i++) {
if ((numbers[i] == -1)) {
boolean impair = nbControlBits(numbers, (i + 1));
if (pair) {
numbers[i] = 0;
}
else {
numbers[i] = 1;
}
}
}
return numbers;
}
void CalculateControlBits(char codeWord[], int length, int nbControlBits)
{
static int[] calculation(int codeword, int Nombredebit)
for (int i = 0; i < Nombredebit; i++) {
int x = (int)Math.pow(2, i);
for (int j = 1; j < codeword.length; j++) {
if (((j >> i) & 1) == 1) {
if (x != j)
codeword[x] = codeword[x] ^ codeword[j];
}
}
}
return codeword;
}
char [] GenerateErrorsInCodeWord (char codeWord[], int lengthCodeWord, double prob) {
int[] lengthCodeWord = new int[legnth];
for (int i = 0; i < numbers.length; i++) {
if (Math.random() < prob) {
lengthCodeWord++;
if (numbers[i] == 0)
numbers[i] = 1;
else
numbers[i] = 0;
}
return numbers;
}
}
char [] CorrectCodeWord (char codeWord[], int lengthCodeWord)
{
int power2=1;
int sum=0;
while(power2 < numbers.length)
{
sum=sum+power2;
power2=power2*2;
}
if(sum==0)
System.out.println(" pas d erreur");
else
{
System.out.println(" erreur dans "+sum);
if(numbers[sum-1]==0)
numbers[sum-1]=1;
else
numbers[sum-1]=0;
}
return numbers;
}
boolean CompareTwoSequence(char sequence1, char sequence2)
{
int Erreur = 0;
if (sequence1[i] != sequence2[i])
for(int i = 0; i < sequence1[i]; i++)
{
if(sequence1[i] != sequence2[i])
{
Erreur++;
}
}
return Erreur;
}
}
class numbers {
public boolean VERBOSE = false;
private int vecteur_information;
private int vecteur_nbErreurs;
private int vecteur_nbBitsControle;
private int lengthTrames;
public numbers(int pro_lengthTrames) {
this.lengthTrames = pro_lengthTrames;
this.vecteur_nbErreurs = new int ();
this.vecteur_nbBitsControle = new List<int>();
}
public final void initialisnumbers(int nbBits) {
this.vecteur_information = new List<int>();
for (int i = 0; (i < nbBits); i++) {
Random random = new Random();
this.vecteur_information.Add(random.Next(0, 2));
}
}
public final void miseEnTrames() {
int nbTrames = (this.vecteur_information.Count() / this.lengthTrames);
int longueurDerniereTrame = (this.vecteur_information.Count() % this.lengthTrames);
int trameInformation;
for (int i = 0; (i < nbTrames); i++) {
trameInformation = this.vecteur_information.GetRange((i * this.lengthTrames), this.lengthTrames);
this.pilote(trameInformation);
}
if ((longueurDerniereTrame != 0)) {a
trameInformation = this.vecteur_information.GetRange((nbTrames * this.lengthTrames), longueurDerniereTrame);
this.pilote(trameInformation);
}
}
public final void pilote(int trameInformation) {
int nbBitControl = 0;
int nbErreurCan = 0;
int nbErreurRecue = 0;
int copieInformation = new int (trameInformation);
Trame objTrame = new Trame();
if (this.VERBOSE) {
Console.Write("Trame information : ");
Trame.afficherMessage(copieInformation);
}
int mesgEncode = objTrame.encodageHamming(copieInformation, ref nbBitControl);
this.vecteur_nbBitsControle.Add(nbBitControl);
if (this.VERBOSE) {
Console.WriteLine(("Nb bit control : " + nbBitControl));
Trame.afficherMessage(mesgEncode);
}
int mesgAvecControle = objTrame.ajouterBitDeControl(mesgEncode);
if (this.VERBOSE) {
Trame.afficherMessage(mesgAvecControle);
}
int mesgRecu = objTrame.passageCanal(mesgEncode, (1 / 25), ref nbErreurCan);
if (this.VERBOSE) {
Trame.afficherMessage(mesgRecu);
System.out.println(("Nb Erreurs canal : " + nbErreursCan));
}
int mesgCorrige = objTrame.corrigerErreur(mesgRecu);
if (this.VERBOSE) {
Trame.afficherMessage(mesgCorrige);
}
int informationRecue = objTrame.extraireInformation(mesgCorrige);
if (this.VERBOSE) {
Trame.afficherMessage(informationRecue);
}
nbErreurRecue = objTrame.calculerNbErreurs(trameInformation, informationRecue);
this.vec_nbErreurs.Add(nbErreursRecues);
if (this.VERBOSE) {
System.out.println(("Nb err entre trame recue et envoyee : " + nbErreursRecues));
System.out.println(" ===================================== ");
}
}
public final void calculeStat(int lengthTrames, int longueurMessage) {
System.out.println(" =============== Statistiques ================ ");
System.out.println(("Longueur des trames : " + this.lengthTrames));
System.out.println("Vecteur du nb d\'erreurs : ");
Trame.afficherMessage(this.vecteur_nbErreurs);
System.out.println("Vecteur du nb de bits de controle : ");
Trame.afficherMessage(this.vecteur_nbBitsControle) ;
double moyenneErreurs = (this.vecteur_nbErreurs.Sum() / this.lengthTrames);
double moyenneBitsControle = this.vecteur_nbBitControl.Average();
System.out.println("Moyenne nb erreurs : ");
System.out.println(moyenneErreurs);
System.out.println("Moyenne nb de bits de controle : ");
System.out.println(moyenneBitsControle);
}
}
class Program {
static void Main(string[] args) {
int lengthTrames;
int lengthnumbers= 3100;
for (lengthTrames = 5; (lengthTrames
< (lengthnumbers / 5)); lengthTrames += 5) {
numbers objnumbers = new numbers(lengthTrames);
objnumbers.initialisnumbers(1000);
objnumbers.miseEnTrames();
objnumbers.calculeStat(lengthTrames, lengthnumbers);
}
for (
; (lengthTrames < lengthnumbers); lengthTrames = (lengthTrames * 2)) {
numbers objnumbers= new numbers(lengthTrames);
objnumbers.initialisnumbers(1000);
objnumbers.miseEnTrames();
objnumbers.calculeStat(lengthTrames, lengthnumbers);
}
}
}