36 lines
923 B
Java
36 lines
923 B
Java
class Aufgabe {
|
|
public static void main(String[] args) {
|
|
Matrix matrix1 = new Matrix(3,1);
|
|
matrix1.setValue(1,1,5);
|
|
matrix1.setValue(2,1,4);
|
|
matrix1.setValue(3,1,8);
|
|
|
|
Matrix matrix2 = new Matrix(3,1);
|
|
matrix2.setValue(1,1,9);
|
|
matrix2.setValue(2,1,3);
|
|
matrix2.setValue(3,1,4);
|
|
|
|
System.out.println("Matrix 1:");
|
|
matrix1.print();
|
|
|
|
System.out.println("Matrix 2:");
|
|
matrix2.print();
|
|
|
|
System.out.println("Matrix 1 nach Multiplikation mit 5:");
|
|
matrix1.multiply(5);
|
|
matrix1.print();
|
|
|
|
System.out.println("Matrix 1 nach Addition mit Matrix 2:");
|
|
matrix1.add(matrix2);
|
|
matrix1.print();
|
|
|
|
System.out.println("Matrix 2 nach Multiplikation mit Matrix 1:");
|
|
try {
|
|
matrix2.multiply(matrix2);
|
|
matrix2.print();
|
|
} catch(MatrixException e) {
|
|
System.out.println("Fehler beim Multiplizieren zweier Matrizen: " + e.getMessage());
|
|
}
|
|
}
|
|
}
|