From dfc96bfc44d462b003c206a3af5eb2cc0adc8383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ko=C5=BEusznik?= <jan@kozusznik.cz> Date: Mon, 25 Oct 2021 13:54:53 +0200 Subject: [PATCH] Add number to tasks. --- src/main/java/cz/jezek/lab11/StreamMain.java | 26 +++++++++++--------- src/main/java/cz/jezek/lab11/Tournament.java | 11 ++++----- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/java/cz/jezek/lab11/StreamMain.java b/src/main/java/cz/jezek/lab11/StreamMain.java index 2c10d9e..9b2b00c 100644 --- a/src/main/java/cz/jezek/lab11/StreamMain.java +++ b/src/main/java/cz/jezek/lab11/StreamMain.java @@ -16,27 +16,29 @@ public class StreamMain { Player player = tournament.getRandomPlayer(); System.out.println(player); - System.out.print("PoÄŤet zápasĹŻ: "); - //TODO Show the number of matches played by a given player (using Streams) - System.out.print("VstĹ™eleno gĂłlĹŻ: "); - //TODO Show the number of goals scored by a given player (help Streams) + System.out.print("Number of matches: "); + //TODO 3.a Show the number of matches played by a given player (using Streams) + + System.out.print("Goals scored: "); + //TODO 3.b Show the number of goals scored by a given player (help Streams) Oponents oponents = new Oponents(tournament.getRandomPlayer(), tournament.getRandomPlayer()); - System.out.println("Statistika vzájemnĂ˝ch zápasĹŻ:" + oponents); - System.out.print("Zápasy: "); - //TODO List the matches played between the given players (using the stream) - System.out.print("PoÄŤet zápasĹŻ: "); - //TODO Print the number of matches played between the given players (using the stream) + System.out.println("Mutual statistics of oponents:" + oponents); + + System.out.print("Matches: "); + //TODO 4.a List the matches played between the given players (using the stream) + System.out.print("Number of mathes: "); + //TODO 4.b Print the number of matches played between the given players (using the stream) System.out.print("Zápas s nejvÄ›tšĂm poÄŤtem branek:"); - //TODO Show match with the largest total number (sum of both players) scored goals between relevant players (help Streams) + //TODO 4.c Show match with the largest total number (sum of both players) scored goals between relevant players (help Streams) } public static void loadTournament() { - //TODO Load a serialized tournament from a file + //TODO 5.b Load a serialized tournament from a file } public static void saveTournament(Tournament tournament) { - //TODO Save the tournament to a file using object serialization. + //TODO 5.a Save the tournament to a file using object serialization. } } diff --git a/src/main/java/cz/jezek/lab11/Tournament.java b/src/main/java/cz/jezek/lab11/Tournament.java index 73b546e..3f22efc 100644 --- a/src/main/java/cz/jezek/lab11/Tournament.java +++ b/src/main/java/cz/jezek/lab11/Tournament.java @@ -9,13 +9,12 @@ public class Tournament { private List<Match> matches; public static Tournament generate() { - List<Player> players = Collections.emptyList(); - - // TODO Generate a list of 10 random players using the stream and then filter so that it does not contain players with the same name + // TODO 1.a Generate a list of 10 random players using the stream and then filter so that it does not contain players with the same name + List<Player> players = Collections.emptyList(); + // TODO 1.b Use the stream to generate a list of 50 matches between random players (from the list of players) with a random result. Make sure the player does not play with himself. List<Match> matches = Collections.emptyList(); - // TODO Use the stream to generate a list of 50 matches between random players (from the list of players) with a random result. Make sure the player does not play with himself. return new Tournament(players, matches); } @@ -45,11 +44,11 @@ public class Tournament { builder.append("\n"); builder.append("\n\nPlayers:\n"); - // TODO Use the stream to add a listing of all players to the builder. Individual players are separated by a "\ n" character + // TODO 2.a Use the stream to add a listing of all players to the builder. Individual players are separated by a "\ n" character builder.append(/* list of all players */""); builder.append("\n\nMatches:\n"); - // TODO Use the stream to add a listing of all entries to the builder. Individual matches are separated by a "\ n" character + // TODO 2.b Use the stream to add a listing of all entries to the builder. Individual matches are separated by a "\ n" character builder.append(/* list of all matches */""); return builder.toString(); -- GitLab