Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TP4;
- import java.util.Random;
- import java.util.Scanner;
- public class Helper {
- Random random = new Random();
- Scanner scanner = new Scanner(System.in);
- public int leerNum (){
- int num = 0 ;
- boolean band = true;
- while (band) {
- print("Ingrese un numero entero positivo");
- try{
- int aux =scanner.nextInt();
- if (aux>0) {
- band=false;
- num=aux;
- } else {
- print("El numero ingresado no cumple la condicion... Ingrese nuevamente\n");
- }
- }catch(Exception e) {
- print("Valor incorrecto... Ingrese nuevamente\n");
- }
- }
- return num;
- }
- public boolean continuar() {
- boolean seguir = true;
- int opc = scanner.nextInt();
- if (opc == 1) {
- seguir= true;
- }else {
- seguir=false;
- print("\n--------------\nFin del programa...\n----------------");
- }
- return seguir;
- }
- public int generarRand () {
- int numRand =(int) (Math.random()*200+1);
- System.out.println("El numero aleatorio genrado es: "+numRand);
- return numRand;
- }
- public void print(String texto) {
- System.out.println(texto);
- }
- public String toString(int num) {
- return Integer.toString(num);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement