Files
Testate/WS2526/Testat 1b/Main.java
T
2026-01-06 15:28:08 +01:00

89 lines
4.4 KiB
Java

import java.util.Arrays;
public class Main {
/**
* Die folgende main-Methode dient Ihnen zur Hilfe, um Ihre Lösungen zutesten.
* Beachten Sie bitte, dass in dieser Methode nicht alle Tests enthalten sind,
* sondern nur einige, die Ihnen helfen sollen, Ihre Lösungen zu überprüfen.
*/
public static void main(String[] args) {
System.out.println();
System.out.println("=========================================");
System.out.println("Aufgabe 1 - Gegenstände");
System.out.println("=========================================");
System.out.println();
// create items
MediaItem longMovie = new Movie(241, "The Lord of the Rings", 5);
MediaItem shortMovie = new Movie(109, "Deadpool", 42);
MediaItem shortSeries = new Series(1230, "SpongeBob", 7);
MediaItem longSeries = new Series(2930, "Breaking Bad", 4);
// Lasting
System.out.println("Expected (Movie.getDuration()): 241");
System.out.println("Your code (Movie.getDuration()): " + longMovie.getDuration());
System.out.println("Expected (Movie.getDuration()): 109");
System.out.println("Your code (Movie.getDuration()): " + shortMovie.getDuration());
System.out.println("Expected (Series.getDuration()): 1230");
System.out.println("Your code (Series.getDuration()): " + shortSeries.getDuration());
System.out.println("Expected (Series.getDuration()): 2930");
System.out.println("Your code (Series.getDuration()): " + longSeries.getDuration());
System.out.println();
// toString
System.out.println("Expected (Movie.toString()): Movie: The Lord of the Rings (5 241 min)");
System.out.println("Your code (Movie.toString()): " + longMovie.toString());
System.out.println();
System.out.println("Expected (Series.toString()): Series: SpongeBob (7 1230 min)");
System.out.println("Your code (Series.toString()): " + shortSeries.toString());
System.out.println();
System.out.println();
System.out.println("=========================================");
System.out.println("Aufgabe 2 - Arrays");
System.out.println("=========================================");
System.out.println();
System.out.println("Input: [1, 2, 3, 4, 5]");
System.out.println("Threshold: 2");
System.out.println("Expected Output: 1.0");
System.out.println("Your output: " + Testat1B.calculateMeanBelow(new int[] { 1, 2, 3, 4, 5 }, 2));
System.out.println();
System.out.println("Input: [-10, 0, 10, 20, 4, -7, 4]");
System.out.println("Threshold: 0");
System.out.println("Expected Output: -8.5");
System.out.println("Your output: " + Testat1B.calculateMeanBelow(new int[] { -10, 0, 10, 20, 4, -7, 4 }, 0));
System.out.println();
System.out.println("Input: null");
System.out.println("Threshold: 5");
System.out.println("Expected Output: 0.0");
System.out.println("Your output: " + Testat1B.calculateMeanBelow(null, 5));
System.out.println();
System.out.println();
System.out.println("=========================================");
System.out.println("Aufgabe 3 - 2d-Arrays");
System.out.println("=========================================");
System.out.println();
int[][] array = { { 1, 2, 3 }, { 4, 5 }, { 6 }, null };
double[] means = Testat1B.calculateColumnMean(array);
System.out.println("Input: [[1, 2, 3], [4, 5], [6], null]");
System.out.println("Expected Output: [2.0, 4.5, 6.0, 0.0]");
System.out.println("Your output: " + Arrays.toString(means));
System.out.println();
array = new int[][] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
means = Testat1B.calculateColumnMean(array);
System.out.println("Input: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]");
System.out.println("Expected Output: [2.0, 5.0, 8.0]");
System.out.println("Your output: " + Arrays.toString(means));
System.out.println();
array = new int[][] { { 1, 2 }, { 1, 2 }, { 1, 2 }, {} };
means = Testat1B.calculateColumnMean(array);
System.out.println("Input: [[1, 2], [1, 2], [1, 2], []]");
System.out.println("Expected Output: [1.5, 1.5, 1.5, 0.0]");
System.out.println("Your output: " + Arrays.toString(means));
System.out.println();
}
}