Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package artur.porebski.controller;
- import artur.porebski.model.Calculations;
- import artur.porebski.view.View;
- import java.util.InputMismatchException;
- /**
- * Main class of the application
- *
- * @author Artur Porębski
- * @version 3.0
- */
- public class Main {
- /**
- * Main method of the application
- *
- * @param args - Takes size of an array as initial parameter
- */
- public static void main(String[] args) {
- int size = 0;
- double[] myArray;
- View view = new View();
- Calculations calculations = new Calculations();
- if (args.length > 0){
- if(args[0].matches(".*[0-9]+.*")) {
- size = Integer.parseInt(args[0]);
- if(size > 0){
- myArray = new double[size];
- view.fillArray(myArray);
- view.displayArray(myArray);
- for (int i=1;i<=9;i++){
- view.displayAllStatistics(calculations.allOpeartions(myArray,i),i);
- }
- while (view.yesOrNo()) {
- boolean error;
- view.displayText(4);
- view.displayText(3);
- do{
- error = false;
- try {
- size = view.getSize(size);
- }catch(InputMismatchException e) {
- error = true;
- view.displayText(9);
- view.displayText(3);
- }
- }while(error);
- while (size <= 0) {
- view.displayText(2);
- size = view.getSize(size);
- }
- if (size > 0) {
- myArray = new double[size];
- view.fillArray(myArray);
- for (int i=0;i<10;i++){
- view.displayAllStatistics(calculations.allOpeartions(myArray,i),i);
- }
- }
- }
- view.displayText(5);
- }
- else {
- view.displayText(6);
- }
- }
- else {
- view.displayText(7);
- }
- }
- else {
- view.displayText(8);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement