Skip to content

Commit 04d6b13

Browse files
PabloPablo
Pablo
authored and
Pablo
committed
Implementación del parametro args
1 parent c120066 commit 04d6b13

File tree

9 files changed

+17
-14
lines changed

9 files changed

+17
-14
lines changed

.DS_Store

6 KB
Binary file not shown.

src/.DS_Store

6 KB
Binary file not shown.

src/postfix/.DS_Store

6 KB
Binary file not shown.

src/postfix/Postfix.class

790 Bytes
Binary file not shown.

src/postfix/Postfix.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,32 @@
66
* Pablo Díaz
77
*/
88

9-
package postfix;
10-
import java.util.Scanner;
9+
1110

1211

1312
public class Postfix {
1413

1514
/**
1615
* @param args the command line arguments
16+
* la entrada de datos se hace por medio del parametro args
17+
* Ejemplo de ejecucion:
18+
* javac PostFix.java
19+
* java Postfix 835*+ 12+4*3+
20+
* Se tiene que dejar un espacio para cada argumento
1721
*/
1822
public static void main(String[] args) {
1923

20-
Scanner entrada_datos = new Scanner(System.in);
24+
2125
//<<<<<<< HEAD
2226
//=======
23-
// Indicación general al usuario
24-
System.out.println("Ingrese expresión en postfix:");
2527
//>>>>>>> origin/master
26-
String entrada = entrada_datos.nextLine();
27-
// Se crea el objeto tipo TPostfix para trabajar la cadena ingresada
28-
TPostfix calc = new TPostfix(entrada);
29-
// Se manda a llamar al método que calcula el valor
30-
// El parámetro 100 es variable, este indica el tamaño de la pila
31-
double res = calc.eval(100);
32-
System.out.println("Resultado: " + res);
28+
29+
for (String s: args) {
30+
// Se crea el objeto tipo TPostfix para trabajar la cadena ingresada
31+
TPostfix calc = new TPostfix(s);
32+
// Se manda a llamar al método que calcula el valor
33+
double res = calc.eval(100);// El parámetro 100 es variable, este indica el tamaño de la pila
34+
System.out.println("Resultado: " + res);
35+
}
3336
}
3437
}

src/postfix/Stack.class

997 Bytes
Binary file not shown.

src/postfix/Stack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Daniel Orozco
66
* Pablo Díaz
77
*/
8-
package postfix;
8+
99

1010

1111
public class Stack {

src/postfix/TPostfix.class

1.68 KB
Binary file not shown.

src/postfix/TPostfix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Daniel Orozco
66
* Pablo Díaz
77
*/
8-
package postfix;
8+
99

1010

1111
public class TPostfix {

0 commit comments

Comments
 (0)