package cap6.matrici;

import IngressoUscita.Console;

public class Menu
{ private static void stampaMatrice(Matrice m)
  { for (int i = 0; i < m.SIZE; i++)
    { for (int j = 0; j < m.SIZE; j++)
        Console.scriviStr(m.get(i, j) + " ");
      Console.nuovaLinea();
    }
  }
  private static Matrice leggiMatrice()
  { Matrice m = new Matrice();
    for (int i = 0; i < m.SIZE; i++)
      for (int j = 0; j < m.SIZE; j++)
      { Console.scriviStringa(
          "Elemento (" + i + ", " + j + ")?");
        m.set(i, j, Console.leggiReale());
      }
    return m;
  }
  public static void main(String[] args)
  { Matrice acc = new Matrice();
    boolean ancora = true;
    while (ancora)
    { stampaMatrice(acc);
      Console.scriviStringa("1) nuova matrice");
      Console.scriviStringa("2) moltiplica per scalare");
      Console.scriviStringa("3) moltiplica per matrice");
      Console.scriviStringa("4) stampa valore assoluto");
      Console.scriviStringa("5) esci");
      switch (Console.leggiIntero())
      { case 1:
          acc = leggiMatrice();
          break;
        case 2:
          Console.scriviStringa("Inserire scalare");
          acc = acc.mul(Console.leggiReale());
          break;
        case 3:
          acc = acc.mul(leggiMatrice());
          break;
        case 4:
          Console.scriviStringa(
            "Valore assoluto: " + acc.abs());
          break;
        case 5:
          ancora = false;
          break;
      }
    }
  }
}
