Advertisement
Artur123ff2

Untitled

Mar 28th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.57 KB | None | 0 0
  1. package artur.porebski.controller;
  2.  
  3. import artur.porebski.model.Calculations;
  4. import artur.porebski.view.View;
  5. import java.util.InputMismatchException;
  6.  
  7. /**
  8.  * Main class of the application
  9.  *
  10.  * @author Artur Porębski
  11.  * @version 3.0
  12.  */
  13. public class Main {
  14.    
  15.     /**
  16.      * Main method of the application
  17.      *
  18.      * @param args - Takes size of an array as initial parameter
  19.      */
  20.     public static void main(String[] args) {
  21.  
  22.         int size = 0;
  23.        
  24.         double[] myArray;
  25.         View view = new View();
  26.         Calculations calculations = new Calculations();
  27.        
  28.        
  29.         if (args.length > 0){
  30.             if(args[0].matches(".*[0-9]+.*")) {
  31.                 size = Integer.parseInt(args[0]);
  32.                 if(size > 0){
  33.  
  34.                     myArray = new double[size];
  35.  
  36.                     view.fillArray(myArray);
  37.                     view.displayArray(myArray);
  38.  
  39.                     for (int i=1;i<=9;i++){
  40.                         view.displayAllStatistics(calculations.allOpeartions(myArray,i),i);
  41.                     }
  42.  
  43.                     while (view.yesOrNo()) {
  44.                         boolean error;
  45.                         view.displayText(4);
  46.                         view.displayText(3);
  47.                         do{
  48.                             error = false;
  49.                             try {
  50.                                 size = view.getSize(size);
  51.                             }catch(InputMismatchException e) {
  52.                                 error = true;
  53.                                 view.displayText(9);
  54.                                 view.displayText(3);
  55.                             }
  56.                         }while(error);
  57.                         while (size <= 0) {
  58.                             view.displayText(2);
  59.                             size = view.getSize(size);
  60.                         }
  61.                         if (size > 0) {
  62.                             myArray = new double[size];
  63.                             view.fillArray(myArray);
  64.                             for (int i=0;i<10;i++){
  65.                                 view.displayAllStatistics(calculations.allOpeartions(myArray,i),i);
  66.                             }
  67.                         }
  68.                     }
  69.                     view.displayText(5);
  70.                 }
  71.                 else {
  72.                     view.displayText(6);
  73.                 }
  74.             }
  75.             else {
  76.                 view.displayText(7);
  77.             }
  78.         }
  79.         else {
  80.             view.displayText(8);
  81.         }
  82.  
  83. }
  84.    
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement