added a debbuging option for our co2 data
This commit is contained in:
parent
1464df11cf
commit
036911b58c
22 changed files with 362 additions and 25 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,9 @@
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
// #region Fields
|
||||
private static final Scanner scanner = new Scanner(System.in);
|
||||
|
||||
private static final int ROOM_COUNT = 3;
|
||||
|
@ -11,6 +13,18 @@ public class App {
|
|||
public static final Lesson[][][] timeTable = new Lesson[ROOM_COUNT][DAY_COUNT][LESSON_COUNT];
|
||||
private static final Teacher[] teachers = new Teacher[Teacher.nameMap.size()];
|
||||
|
||||
// Get data from the last 8'000 entries seeing as that is the maximum
|
||||
private static final List<Co2Data> room39Data = Co2Data.getData(
|
||||
"https://api.thingspeak.com/channels/1521262/feeds.csv?results=8000",
|
||||
39);
|
||||
private static final List<Co2Data> room38Data = Co2Data.getData(
|
||||
"https://api.thingspeak.com/channels/1364580/feeds.csv?results=8000",
|
||||
38);
|
||||
private static final List<Co2Data> room37Data = Co2Data.getData(
|
||||
"https://api.thingspeak.com/channels/1521263/feeds.csv?results=8000",
|
||||
37);
|
||||
|
||||
// #region Initialization
|
||||
private static void initializeTeachers() {
|
||||
int index = 0;
|
||||
for (String initial : Teacher.nameMap.keySet()) {
|
||||
|
@ -24,6 +38,7 @@ public class App {
|
|||
FillTable.fill39TimeTable();
|
||||
}
|
||||
|
||||
// #region Calculations
|
||||
private static void calculatePoints() {
|
||||
// Point calculation logic
|
||||
}
|
||||
|
@ -33,6 +48,7 @@ public class App {
|
|||
(a, b) -> Integer.compare(b.getPoints().getTotalPoints(), a.getPoints().getTotalPoints()));
|
||||
}
|
||||
|
||||
// #region Input - Output handler
|
||||
private static void printTeachers() {
|
||||
int rank = 1;
|
||||
int previousPoints = -1;
|
||||
|
@ -88,25 +104,46 @@ public class App {
|
|||
System.out.println("Goodbye!");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
fillInTimeTable();
|
||||
initializeTeachers();
|
||||
calculatePoints();
|
||||
sortTeachers();
|
||||
printTeachers();
|
||||
|
||||
int userInput = getUserInput(
|
||||
"Do you want to see how the points were calculated? (Yes 1, No 0; anything is an error)");
|
||||
|
||||
if (userInput == 1) {
|
||||
printExplanation();
|
||||
printShutDown();
|
||||
} else if (userInput == 0) {
|
||||
printShutDown();
|
||||
} else {
|
||||
System.out.println("Invalid input. Please enter 1 for Yes or 0 for No.");
|
||||
// @TODO: remove this before hand-in deadline
|
||||
public static void debbugingValueLists(List<Co2Data> data) {
|
||||
// Debugging co2Data
|
||||
int index = 0;
|
||||
for (Co2Data a : room37Data) {
|
||||
System.out.println(a.toString());
|
||||
index++;
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
System.out.println("-----------------");
|
||||
System.out.println(index);
|
||||
}
|
||||
|
||||
// #region Main
|
||||
public static void main(String[] args) {
|
||||
boolean debbugingList = true;
|
||||
if (debbugingList) {
|
||||
debbugingValueLists(room37Data);
|
||||
// debbugingValueLists(room38Data);
|
||||
// debbugingValueLists(room39Data);
|
||||
} else {
|
||||
fillInTimeTable();
|
||||
initializeTeachers();
|
||||
calculatePoints();
|
||||
sortTeachers();
|
||||
printTeachers();
|
||||
|
||||
int userInput = getUserInput(
|
||||
"Do you want to see how the points were calculated? (Yes 1, No 0; anything is an error)");
|
||||
|
||||
if (userInput == 1) {
|
||||
printExplanation();
|
||||
printShutDown();
|
||||
} else if (userInput == 0) {
|
||||
printShutDown();
|
||||
} else {
|
||||
System.out.println("Invalid input. Please enter 1 for Yes or 0 for No.");
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,13 @@ public class Co2Data {
|
|||
private Date date;
|
||||
private int co2Level;
|
||||
|
||||
// #region Constructor
|
||||
public Co2Data(Date date, int co2Level) {
|
||||
this.date = date;
|
||||
this.co2Level = co2Level;
|
||||
}
|
||||
|
||||
// #region Getters Setters
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
@ -30,9 +32,13 @@ public class Co2Data {
|
|||
this.co2Level = co2Level;
|
||||
}
|
||||
|
||||
// #region Fetching & Parsing
|
||||
public static List<Co2Data> getData(String csvURL, int classRoomNumber) {
|
||||
List<Co2Data> dataList = new ArrayList<>();
|
||||
|
||||
// Reference date: August 11, 2024
|
||||
Date referenceDate = new Date(11, 8, 2024, 0, 0); // Set time to 00:00 as we only care about the date
|
||||
|
||||
try {
|
||||
URL url = new URL(csvURL);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
|
@ -52,7 +58,7 @@ public class Co2Data {
|
|||
|
||||
while ((output = br.readLine()) != null) {
|
||||
Co2Data data = parseData(output, classRoomNumber);
|
||||
if (data != null) {
|
||||
if (data != null && isNewerThanReferenceDate(data.getDate(), referenceDate)) {
|
||||
dataList.add(data);
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +71,21 @@ public class Co2Data {
|
|||
return dataList; // Return the list of Co2Data objects
|
||||
}
|
||||
|
||||
// Helper method to compare dates
|
||||
private static boolean isNewerThanReferenceDate(Date dataDate, Date referenceDate) {
|
||||
// Compare year, month, and day only (ignoring the time part)
|
||||
if (dataDate.getYear() > referenceDate.getYear()) {
|
||||
return true;
|
||||
} else if (dataDate.getYear() == referenceDate.getYear()) {
|
||||
if (dataDate.getMonth() > referenceDate.getMonth()) {
|
||||
return true;
|
||||
} else if (dataDate.getMonth() == referenceDate.getMonth()) {
|
||||
return dataDate.getDay() > referenceDate.getDay();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Co2Data parseData(String csvLine, int classRoomNumber) {
|
||||
String[] fields = csvLine.split(",");
|
||||
if (fields.length < 5) {
|
||||
|
@ -95,4 +116,10 @@ public class Co2Data {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// #region toString Override
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.date.toString() + "\n" + this.co2Level;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,27 @@
|
|||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
public class Date {
|
||||
// #region Fields
|
||||
private int day;
|
||||
private int month;
|
||||
private int year;
|
||||
private int hour;
|
||||
private int minute;
|
||||
|
||||
// #region Constructor
|
||||
public Date(int day, int month, int year, int hour, int minute) {
|
||||
this.day = day;
|
||||
this.month = month;
|
||||
this.year = year;
|
||||
this.hour = hour;
|
||||
this.minute = minute;
|
||||
|
||||
// Automatically adjust for Switzerland time after initialization
|
||||
adjustForSwitzerlandTime();
|
||||
}
|
||||
|
||||
// Getters
|
||||
// #region Getters
|
||||
public int getDay() {
|
||||
return day;
|
||||
}
|
||||
|
@ -34,6 +42,62 @@ public class Date {
|
|||
return minute;
|
||||
}
|
||||
|
||||
// #region Helper Method to Check Daylight Saving Time
|
||||
private boolean isDaylightSavingTime() {
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.set(year, month - 1, day); // Month is 0-based in Calendar
|
||||
|
||||
// Last Sunday in March (DST starts)
|
||||
Calendar lastSundayInMarch = new GregorianCalendar(year, Calendar.MARCH, 31);
|
||||
lastSundayInMarch.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
|
||||
lastSundayInMarch.add(Calendar.DATE, -7); // Go back to last Sunday of March
|
||||
|
||||
// Last Sunday in October (DST ends)
|
||||
Calendar lastSundayInOctober = new GregorianCalendar(year, Calendar.OCTOBER, 31);
|
||||
lastSundayInOctober.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
|
||||
lastSundayInOctober.add(Calendar.DATE, -7); // Go back to last Sunday of October
|
||||
|
||||
// Check if the current date is within the DST period
|
||||
return calendar.after(lastSundayInMarch) && calendar.before(lastSundayInOctober);
|
||||
}
|
||||
|
||||
// #region Adjust UTC to Switzerland Time
|
||||
private void adjustForSwitzerlandTime() {
|
||||
if (isDaylightSavingTime()) {
|
||||
// Switzerland is UTC +2 during DST (CEST)
|
||||
hour += 2;
|
||||
} else {
|
||||
// Switzerland is UTC +1 during Standard Time (CET)
|
||||
hour += 1;
|
||||
}
|
||||
|
||||
// Adjust if the hour exceeds 24 or falls below 0
|
||||
if (hour >= 24) {
|
||||
hour -= 24;
|
||||
day++;
|
||||
if (day > 31) { // Simple month/day rollover, could be more sophisticated
|
||||
day = 1;
|
||||
month++;
|
||||
if (month > 12) {
|
||||
month = 1;
|
||||
year++;
|
||||
}
|
||||
}
|
||||
} else if (hour < 0) {
|
||||
hour += 24;
|
||||
day--;
|
||||
if (day < 1) {
|
||||
month--;
|
||||
if (month < 1) {
|
||||
month = 12;
|
||||
year--;
|
||||
}
|
||||
day = 31; // Simple month/day rollover, could be more sophisticated
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #region toString Override
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%04d-%02d-%02d %02d:%02d", year, month, day, hour, minute);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
public class FillTable {
|
||||
// #region Constants
|
||||
private static final String[] START_TIMES = {
|
||||
"7:45", "8:35", "9:40", "10:30", "11:20", "12:10", "12:50",
|
||||
"13:35", "14:25", "15:15", "16:15", "17:05"
|
||||
|
@ -10,6 +10,7 @@ public class FillTable {
|
|||
"14:20", "15:10", "16:10", "17:00", "17:50"
|
||||
};
|
||||
|
||||
// #region Helper Methods
|
||||
private static void fillTable(String[] teacherShortNames, String day, String[] startTime, String[] endTime,
|
||||
int roomIndex) {
|
||||
int dayIndex = getDayIndex(day);
|
||||
|
@ -37,6 +38,7 @@ public class FillTable {
|
|||
}
|
||||
}
|
||||
|
||||
// #region Fill 37
|
||||
static void fill37TimeTable() {
|
||||
int roomIndex = 0;
|
||||
fillTable(new String[] { "Hm", "Hm", "Hi", "Hm", "Hm", "Lunch", "Bd", "Gi", "Gi", "Ts", "Ts", "" },
|
||||
|
@ -51,6 +53,7 @@ public class FillTable {
|
|||
"Friday", START_TIMES, END_TIMES, roomIndex);
|
||||
}
|
||||
|
||||
// #region Fill 38
|
||||
static void fill38TimeTable() {
|
||||
int roomIndex = 1;
|
||||
fillTable(new String[] { "Bz", "Bz", "Bz", "Bz", "Bz", "Lunch", "Lunch", "Hn", "Hn", "Bu", "Hn", "Hn" },
|
||||
|
@ -65,6 +68,7 @@ public class FillTable {
|
|||
"Friday", START_TIMES, END_TIMES, roomIndex);
|
||||
}
|
||||
|
||||
// #region Fill 39
|
||||
static void fill39TimeTable() {
|
||||
int roomIndex = 2;
|
||||
fillTable(new String[] { "Bd", "Bd", "Bd", "Bd", "Bd", "Lunch", "Lunch", "Lu", "Lu", "Lu", "Lu", "" },
|
||||
|
@ -78,4 +82,5 @@ public class FillTable {
|
|||
fillTable(new String[] { "Gi", "Gi", "Gr", "Gr", "Gi", "Lunch", "Lunch", "Hi", "Hi", "Hi", "", "" },
|
||||
"Friday", START_TIMES, END_TIMES, roomIndex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
public class Lesson {
|
||||
// #region Fields
|
||||
private int roomNumberNumber;
|
||||
private String teacherInitials;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private String weekweekDay;
|
||||
|
||||
// #region Constructor
|
||||
// Constructor to initialize all fields
|
||||
public Lesson(int roomNumber, String teacherInitials, String startTime, String endTime, String weekweekDay) {
|
||||
this.roomNumberNumber = roomNumber;
|
||||
|
@ -14,7 +16,7 @@ public class Lesson {
|
|||
this.weekweekDay = weekweekDay;
|
||||
}
|
||||
|
||||
// Getters
|
||||
// #region Getters
|
||||
public int getroomNumber() {
|
||||
return roomNumberNumber;
|
||||
}
|
||||
|
@ -34,4 +36,5 @@ public class Lesson {
|
|||
public String getweekDay() {
|
||||
return weekweekDay;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
// Points class for managing point categories
|
||||
public class Points {
|
||||
// #region Fields
|
||||
private int fiveMinuteBreak;
|
||||
private int longerBreak;
|
||||
private int bonusPoints;
|
||||
|
||||
// #region Getters Setters
|
||||
public int getFiveMinuteBreak() {
|
||||
return fiveMinuteBreak;
|
||||
}
|
||||
|
@ -28,8 +30,10 @@ public class Points {
|
|||
this.bonusPoints = bonusPoints;
|
||||
}
|
||||
|
||||
// #region Calculation
|
||||
// Method to calculate total points
|
||||
public int getTotalPoints() {
|
||||
return fiveMinuteBreak + longerBreak + bonusPoints;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,10 +2,13 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
public class Teacher {
|
||||
// #region Fields
|
||||
private String name;
|
||||
private Points points;
|
||||
|
||||
public static final Map<String, String> nameMap = new HashMap<>();
|
||||
|
||||
// #region Initialization
|
||||
static {
|
||||
nameMap.put("Hm", "Hummel");
|
||||
nameMap.put("Bd", "Bender");
|
||||
|
@ -29,11 +32,14 @@ public class Teacher {
|
|||
nameMap.put("Zu", "Zuniga");
|
||||
}
|
||||
|
||||
|
||||
// #region Constructor
|
||||
public Teacher(String name) {
|
||||
this.name = nameMap.getOrDefault(name, "Unknown");
|
||||
this.points = new Points();
|
||||
}
|
||||
|
||||
// #region Getters
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -41,4 +47,5 @@ public class Teacher {
|
|||
public Points getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
7
Code/Steiner/Oopdokument/.vscode/settings.json
vendored
Normal file
7
Code/Steiner/Oopdokument/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
18
Code/Steiner/Oopdokument/README.md
Normal file
18
Code/Steiner/Oopdokument/README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
BIN
Code/Steiner/Oopdokument/bin/Dokument.class
Normal file
BIN
Code/Steiner/Oopdokument/bin/Dokument.class
Normal file
Binary file not shown.
BIN
Code/Steiner/Oopdokument/bin/Dokumenttest.class
Normal file
BIN
Code/Steiner/Oopdokument/bin/Dokumenttest.class
Normal file
Binary file not shown.
BIN
Code/Steiner/Oopdokument/src/Dokument.class
Normal file
BIN
Code/Steiner/Oopdokument/src/Dokument.class
Normal file
Binary file not shown.
68
Code/Steiner/Oopdokument/src/Dokument.java
Normal file
68
Code/Steiner/Oopdokument/src/Dokument.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
public class Dokument {
|
||||
private String titel;
|
||||
private String text;
|
||||
private String dateiFormat;
|
||||
|
||||
// Konstruktor mit Validierung des Dateiformats
|
||||
public Dokument(String dateiFormat) {
|
||||
// Default-Werte für Titel und Text
|
||||
this.titel = "";
|
||||
this.text = "";
|
||||
|
||||
// Validierung des Dateiformats
|
||||
if (dateiFormat.equalsIgnoreCase("pdf") || dateiFormat.equalsIgnoreCase("doc")
|
||||
|| dateiFormat.equalsIgnoreCase("docx")) {
|
||||
this.dateiFormat = dateiFormat.toLowerCase();
|
||||
} else {
|
||||
this.dateiFormat = "pdf"; // Default-Wert im Fehlerfall
|
||||
}
|
||||
}
|
||||
|
||||
// Getter für den Titel
|
||||
public String getTitel() {
|
||||
return titel;
|
||||
}
|
||||
|
||||
// Setter für den Titel
|
||||
public void setTitel(String titel) {
|
||||
this.titel = titel;
|
||||
}
|
||||
|
||||
// Getter für den Text
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
// Setter für den Text
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
// Getter für das Dateiformat
|
||||
public String getDateiFormat() {
|
||||
return dateiFormat;
|
||||
}
|
||||
|
||||
// Methode, die Infos zum Dokument ausgibt
|
||||
public void zeigeInfo() {
|
||||
System.out.println("Titel: " + titel);
|
||||
System.out.println("Text: " + text);
|
||||
System.out.println("Dateiformat: " + dateiFormat);
|
||||
}
|
||||
|
||||
// Methode zur Berechnung der Anzahl Zeichen im Text
|
||||
public int anzahlZeichen() {
|
||||
return text.length();
|
||||
}
|
||||
|
||||
// Methode zur Berechnung der Anzahl Sätze im Text
|
||||
public int anzahlSaetze() {
|
||||
int anzahl = 0;
|
||||
for (char c : text.toCharArray()) {
|
||||
if (c == '.' || c == ':' || c == '?' || c == '!') {
|
||||
anzahl++;
|
||||
}
|
||||
}
|
||||
return anzahl;
|
||||
}
|
||||
}
|
BIN
Code/Steiner/Oopdokument/src/Dokumenttest.class
Normal file
BIN
Code/Steiner/Oopdokument/src/Dokumenttest.class
Normal file
Binary file not shown.
97
Code/Steiner/Oopdokument/src/Dokumenttest.java
Normal file
97
Code/Steiner/Oopdokument/src/Dokumenttest.java
Normal file
|
@ -0,0 +1,97 @@
|
|||
import java.util.ArrayList;
|
||||
|
||||
public class Dokumenttest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// ArrayList für die Dokumente
|
||||
ArrayList<Dokument> dokumente = new ArrayList<>();
|
||||
|
||||
// Erstellen und Hinzufügen von Dokumenten
|
||||
dokumente.add(createDokument(
|
||||
"pdf",
|
||||
"PDF-Dokument 1",
|
||||
"Dies ist das erste PDF-Dokument. Es enthält mehrere Sätze. Es dient als Beispiel."));
|
||||
dokumente.add(createDokument(
|
||||
"pdf",
|
||||
"PDF-Dokument 2",
|
||||
"Das zweite PDF-Dokument folgt nun. Es zeigt einen weiteren Text. Auch dieser hat mehrere Sätze!"));
|
||||
dokumente.add(createDokument(
|
||||
"doc",
|
||||
"DOC-Dokument 1",
|
||||
"Dies ist das erste DOC-Dokument. Es hat einen anderen Text. Auch dieses Dokument enthält mehrere Sätze."));
|
||||
dokumente.add(createDokument(
|
||||
"doc",
|
||||
"DOC-Dokument 2",
|
||||
"Das zweite DOC-Dokument enthält ebenfalls einen Text. Hier gibt es viele Details. Aber keine Fragezeichen."));
|
||||
dokumente.add(createDokument(
|
||||
"doc",
|
||||
"DOC-Dokument 3",
|
||||
"Das dritte DOC-Dokument enthält interessante Informationen. Es sind viele Punkte hier. Schauen wir uns den Text an."));
|
||||
dokumente.add(createDokument(
|
||||
"docx",
|
||||
"DOCX-Dokument 1",
|
||||
"Dies ist das erste DOCX-Dokument. Der Text ist etwas anders. Wir haben jetzt neue Formatierungen!"));
|
||||
dokumente.add(createDokument(
|
||||
"docx",
|
||||
"DOCX-Dokument 2",
|
||||
"Das zweite DOCX-Dokument zeigt die neue Funktionalität. Es gibt keine großen Überraschungen. Doch die Struktur ist interessant."));
|
||||
|
||||
// Ausgabe der Informationen der Dokumente
|
||||
printAllDocumentsInfo(dokumente);
|
||||
|
||||
// Ausgabe der PDF-Dokumente
|
||||
printSpecificDocuments(dokumente, "pdf");
|
||||
|
||||
// Berechnung und Ausgabe der Zeichen und Sätze in DOC- und DOCX-Dokumenten
|
||||
printTotalCharactersAndSentences(dokumente, "doc");
|
||||
printTotalCharactersAndSentences(dokumente, "docx");
|
||||
}
|
||||
|
||||
// Methode zum Erstellen und Zurückgeben eines neuen Dokuments
|
||||
private static Dokument createDokument(String format, String titel, String text) {
|
||||
Dokument dokument = new Dokument(format);
|
||||
dokument.setTitel(titel);
|
||||
dokument.setText(text);
|
||||
return dokument;
|
||||
}
|
||||
|
||||
// Ausgabe der Informationen aller Dokumente
|
||||
private static void printAllDocumentsInfo(ArrayList<Dokument> dokumente) {
|
||||
System.out.println("=== Ausgabe der Aller Dokumente ===");
|
||||
for (Dokument doc : dokumente) {
|
||||
doc.zeigeInfo();
|
||||
System.out.println("Anzahl Zeichen: " + doc.anzahlZeichen());
|
||||
System.out.println("Anzahl Sätze: " + doc.anzahlSaetze());
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
// Ausgabe von Dokumenten eines bestimmten Formats
|
||||
private static void printSpecificDocuments(ArrayList<Dokument> dokumente, String format) {
|
||||
System.out.println("=== Ausgabe der " + format.toUpperCase() + "-Dokumente ===");
|
||||
for (Dokument doc : dokumente) {
|
||||
if (doc.getDateiFormat().equalsIgnoreCase(format)) {
|
||||
System.out.println(doc.getTitel());
|
||||
System.out.println(doc.getText());
|
||||
System.out.println("=================================================");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void printTotalCharactersAndSentences(ArrayList<Dokument> dokumente, String format) {
|
||||
int gesamtZeichen = 0;
|
||||
int gesamtSaetze = 0;
|
||||
for (Dokument doc : dokumente) {
|
||||
if (doc.getDateiFormat().equalsIgnoreCase(format)) {
|
||||
gesamtZeichen += doc.anzahlZeichen();
|
||||
}
|
||||
gesamtSaetze += doc.anzahlSaetze();
|
||||
}
|
||||
|
||||
// Ausgabe der Gesamtzeichen und -sätze
|
||||
System.out.println("\n=== Gesamtzahl der Zeichen in " + format.toUpperCase() + "-Dokumenten ===");
|
||||
System.out.println("Gesamtzeichen: " + gesamtZeichen);
|
||||
System.out.println("\n=== Gesamtzahl der Sätze in ALLEN-Dokumenten ===");
|
||||
System.out.println("Gesamtzahl Sätze: " + gesamtSaetze);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue