Advertisement
ARIELCARRARO

Entrada.groovy

Dec 28th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.92 KB | None | 0 0
  1. /**
  2.  * @file Entrada.groovy
  3.  * @version 0.1
  4.  * @author Ariel Carraro
  5.  * @date   28.diciembre.2012
  6.  * @url   codemonkey
  7.  * @description Programa para introducir datos tipo int y String
  8.  */
  9.  
  10. import java.util.Scanner
  11. class Entrada{
  12.  
  13.   //introducir datos de tipo "int"
  14.   def enteros(){
  15.     Scanner e=new Scanner(System.in)
  16.     def entero= e.nextInt()
  17.     return entero
  18.   }
  19.  
  20.   //introducir datos de tipo "String"
  21.    def cadenas(){
  22.    Scanner  c= new Scanner()
  23.    def cadena=c.nextLine()
  24.    return cadena
  25.    }
  26. } //fin clase Entrada
  27.  
  28. def activaEntero(entero){
  29.   println "Introduce tu edad: "
  30.   def edad=entero.enteros()
  31.   println " tienes ${edad} años de edad"
  32. }
  33.  
  34. def activaCadena(cadena){
  35.  println "Introduce tu nombre: "
  36.   def nombre=entero.cadenas()
  37.   println "Hola ${nombre} "
  38. }
  39.  
  40. //método principal del programa
  41. static main(args){
  42.  activaCadena(new Entrada())
  43.  activaEntero(new Entrada())
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement