From d81efeebad4aa4cc4b8cde29b93a0e48ff1cbd51 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 29 Nov 2005 02:55:28 +0000 Subject: [PATCH] Agrego parametros por linea de comando. --- src/filosofos3.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/filosofos3.java b/src/filosofos3.java index 33d8fd1..5d35874 100644 --- a/src/filosofos3.java +++ b/src/filosofos3.java @@ -116,13 +116,27 @@ public class filosofos3 { static public void main (String[] args) { - int n = 5; + int n; int i; + int cant; + + if (args.length < 2) { + /* Java parece no poner en args[0] el caller -.- .. Java Sucks :P */ + System.out.println ("Modo de uso: java filosofo3 "); + return; + } + n = Integer.parseInt (args[0]); + if (n < 2) { + System.out.println ("Debe haber por lo menos 2 chinos"); + return; + } + + cant = Integer.parseInt (args[1]); Palitos p = new Palitos (n); for (i=0; i