mercredi 18 novembre 2020

How to match specified char order between 2 random char array in Java?

so basically if the Virus Code has a sequence string code of ABC, then the Virus Code will be matched with the Vaccine Code for example ABABCCAABC.

If the sequence of Virus Code is found in the Vaccine Code then it will return true. otherwise, it will return false.

    virusCode = new char[]{'A', 'B', 'C'};
    lengthCode = new char[3];
    codeSequence = new Random();
    for (int i = 0; i < lengthCode.length; i++) {
        lengthCode[i] = virusCode[codeSequence.nextInt(virusCode.length)];
        System.out.print(lengthCode[i]);
    }

    getVaccineCode = new char[]{'A', 'B', 'C'};
    getLengthCode = new char[20];
    getCodeSequence = new Random();
    for (int i = 0; i < getLengthCode.length; i++) {
        getLengthCode[i] = getVaccineCode[getCodeSequence.nextInt(getVaccineCode.length)];
        System.out.print(getLengthCode[i]);
    }



Aucun commentaire:

Enregistrer un commentaire