You are on page 1of 11

Estado de aceptacin G

Estado de aceptacin H

Estado de aceptacin I

////////////////////////////////////////// /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package AutomataImposi;

/**
*
* @author Dave
*/

/*
* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates


* and open the template in the editor.
*/

/**
*
* @author Dave
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

import java.util.Scanner;

public class Masenredadoquenunck {//nombre de la clase

char arreglo[] = new char[50];//crea un arreglo


int n = 0;//inicia contador
int x;//declara variables

public void rey (String lectura) {


char array[] = lectura.toCharArray();
for (int i = 0; i < array.length; i++) {//inicia ciclo for
arreglo[i] = array[i];//guarda los datos de entrada
}//finaliza ciclo for
n = array.length;
}

///////////////////////////////////////////////////////////////////////////////////Estado A
public void A() {//inicia metodo
while (x < n) {
if (arreglo[x] == '0') {
System.out.println("------>Translacion a Edo. B");
x++;
B();
}
if (arreglo[x] == '1') {
System.out.println("------>Translacion a Edo. C");
x++;
C();
} else {
System.out.println("Error");
System.exit(0);
}
}
}

///////////////////////////////////////////////////////////////////////////////////Estado B
public void B() {//inicia metodov
while ((arreglo[x] == '0') ) {
x++;
System.out.println("<----->Retorna a Edo B");
B();
}
if (arreglo[x] == '1') {
System.out.println("------>Translacion a Edo. D");
x++;
D();

}else {
System.out.println("Error");
System.exit(0);
}
}

///////////////////////////////////////////////////////////////////////////////////Estado C
public void C() {//inicia metodo
while (x < n) {
//System.out.println("Translacion a Edo 1");
while ((arreglo[x] == '1') ) {
x++;
System.out.println("<----->Retorna a Edo C");
C();
}

if (arreglo[x] == '0') {
System.out.println("------>Translacion a Edo. E");
x++;
E();
}

else {
System.out.println("Error");
System.exit(0);
}
}
}

///////////////////////////////////////////////////////////////////////////////////Estado D
public void D() {//inicia metodo
if (arreglo[x] == '0') {
System.out.println("------>Translacion a Edo. F");
x++;
F();
}
if (arreglo[x] == '1'){
System.out.println("------>Translacion a Edo. G");
x++;
G();

}
else {
System.out.println("Error");
System.exit(0);
}
}

///////////////////////////////////////////////////////////////////////////////////Estado E
public void E() {//inicia metodo
if (arreglo[x] == '0') {
System.out.println("------>Translacion a Edo. B");
x++;
B();
}
if (arreglo[x] == '1') {
System.out.println("------>Translacion a Edo. H");
x++;

H();

}
else {
System.out.println("Error");
System.exit(0);
}
}
///////////////////////////////////////////////////////////////////////////////////Estado F
public void F() {//inicia metodo
if (arreglo[x] == '0') {
System.out.println("------>Translacion a Edo. B");
x++;
B();
}
if (arreglo[x] == '1') {
System.out.println("------>Translacion a Edo. I");
x++;
I();
}

else {
System.out.println("Error");
System.exit(0);
}
}
///////////////////////////////////////////////////////////////////////////////////Estado G
public void G() {//inicia metodo
if (arreglo[x] == '0') {
System.out.println("------>Translacion a Edo. E");

x++;
E();
}
if (arreglo[x] == '1') {
System.out.println("------>Translacion a Edo. C");
x++;
C();
}

else {
System.out.println("CADENA ACEPTADA POR EL AFD!!! :D ");
System.exit(0);
}
}

///////////////////////////////////////////////////////////////////////////////////Estado H
public void H() {
if (arreglo[x] == '0') {
System.out.println("------>Translacion a Edo. F");
x++;
F();
}
if (arreglo[x] == '1' ) {
System.out.println("------>Translacion a Edo. G");
x++;
G();
}

else {
System.out.println("CADENA ACEPTADA POR EL AFD!!! :D ");

System.exit(0);
}

}
public void I() {
if (arreglo[x] == '0') {
System.out.println("------>Translacion a Edo. F");
x++;
F();
}
if (arreglo[x] == '1' ) {
System.out.println("------>Translacion a Edo. G");
x++;
G();
}

else {
System.out.println("CADENA ACEPTADA POR EL AFD!!! :D ");
System.exit(0);
}

}
}

///////////////////////////////////////////////////
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package AutomataImposi;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

import java.util.Scanner;

/**
*
* @author Dave
*/
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Realizado por: Alexander Francisco Lopez");
System.out.println("||||||||||||||||||||||||||||||||||||||||||");
System.out.println("===================================
=======");
System.out.println("---Escriba Automata Finito Determinista---");
System.out.println("===================================
=======");
System.out.println("||||||||||||||||||||||||||||||||||||||||||");
System.out.println("::::::::::::::::::::::::::::::::::::::::::");
String aut = sc.next();
Masenredadoquenunck call = new Masenredadoquenunck();
call.rey(aut);

call.A();

}
}
/////////////////////////////////////////////////

You might also like