Alexis-Coria

Tp03-Punto06

Oct 13th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. import java.util.*;
  2. public class Tp3Ej6 {
  3. public static void main(String[] args) {
  4. Queue imprimir = new Queue<>();
  5. Scanner entrada = new Scanner(System.in);
  6. int cont =0;
  7. while (cont!=3){
  8. switch(cont){
  9. case 1:
  10. cargarDocumento(entrada,imprimir);
  11. while(!imprimir.estaVacia()){
  12. System.out.println(imprimir.pool());
  13. }
  14. break;
  15. case 2:
  16. documentoRandom(entrada,imprimir);
  17. while(!imprimir.estaVacia()){
  18. System.out.println(imprimir.pool());
  19. }
  20. break;
  21. }
  22. cont=Helper.validarNumero(entrada, "'opcion' \n1-Manual \n2-Random \n3-Salir");
  23. }
  24. }
  25.  
  26. public static void cargarDocumento(Scanner entrada, Queue imprimir) {
  27. Documento documento;
  28. String nombre,tamaño,preferencia;
  29. int cantidad,numeroDeCopias,continuar=1;
  30. while(continuar!=2){
  31. nombre = Helper.cargarLetra(entrada, "ingresar nombre");
  32. cantidad = Helper.validarNumero(entrada, "ingresar cantidad de hojas");
  33. tamaño = elegirTamaño(entrada);
  34. numeroDeCopias = Helper.validarNumero(entrada, "ingresar numero de copia");
  35. preferencia = preferenciaImprimir(entrada);
  36. documento = new Documento(nombre, cantidad, tamaño, numeroDeCopias, preferencia);
  37. imprimir.offer(documento);
  38. continuar = Helper.elegirOpcion(entrada,"'opcion' \n1-Seguir Cargando \n2-Salir");
  39. }
  40. }
  41.  
  42. private static String preferenciaImprimir(Scanner entrada) {
  43. int opcion =0;
  44. while(true){
  45. if(opcion ==1){
  46. return "Color";
  47. }
  48. if(opcion ==2){
  49. return "Escala Grises";
  50. }
  51. opcion = Helper.validarNumero(entrada,"'Opcion de Preferencia' \n1-Color \n2-Escala en Grises");
  52. }
  53. }
  54.  
  55. public static String elegirTamaño(Scanner entrada) {
  56. int opcion =0;
  57. while(true){
  58. if(opcion ==1){
  59. return "A4";
  60. }
  61. if(opcion ==2){
  62. return "Oficio";
  63. }
  64. if(opcion ==3){
  65. return "Carta";
  66. }
  67. opcion = Helper.validarNumero(entrada,"'Opcion de Tamaño' \n1-A4 \n2-Oficio \n3-Carta");
  68. }
  69. }
  70.  
  71. public static void documentoRandom(Scanner entrada, Queue imprimir) {
  72. Documento documento;
  73. String nombre,tamaño,preferencia;
  74. int cantidad,numeroDeCopias,continuar=1;
  75. while(continuar!=2){
  76. nombre = Helper.nombreRandom("Generando nombre aleatorio...");
  77. cantidad = Helper.generarRandom ("Generando cantidad de hojas...",100);
  78. tamaño = tamañoRandom();
  79. numeroDeCopias = Helper.generarRandom("Generando numero de copia...",100);
  80. preferencia = preferenciaRandom();
  81. documento = new Documento(nombre, cantidad, tamaño, numeroDeCopias, preferencia);
  82. imprimir.offer(documento);
  83. continuar = Helper.elegirOpcion(entrada,"'opcion' \n1-Seguir Cargando \n2-Salir");
  84. }
  85. }
  86.  
  87. private static String preferenciaRandom() {
  88. int opcion =0;
  89. while(true){
  90. if(opcion ==1){
  91. return "Color";
  92. }
  93. if(opcion ==2){
  94. return "Escala Grises";
  95. }
  96. opcion = Helper.generarRandom("Seleccionando preferencia...",2);
  97. }
  98. }
  99.  
  100. public static String tamañoRandom() {
  101. int opcion =0;
  102. while(true){
  103. if(opcion ==1){
  104. return "A4";
  105. }
  106. if(opcion ==2){
  107. return "Oficio";
  108. }
  109. if(opcion ==3){
  110. return "Carta";
  111. }
  112. opcion = Helper.generarRandom("Seleccionando tamaño...",3);
  113. }
  114. }
  115.  
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment