Add description
This commit is contained in:
@@ -19,25 +19,12 @@ public class SchoolJournalImpl implements SchoolJournal {
|
||||
|
||||
@Override
|
||||
public Map<String, Float> getAverageScorePerStudent() {
|
||||
Map<String, Float> averageScores = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, List<Integer>> entry : studentsScores.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
List<Integer> scores = entry.getValue();
|
||||
|
||||
float averageScore = (float) scores.stream().mapToInt(s -> s).average().orElse(0f);
|
||||
|
||||
averageScores.put(name, averageScore);
|
||||
}
|
||||
|
||||
return averageScores;
|
||||
|
||||
// return studentsScores.entrySet().stream()
|
||||
// .collect(Collectors.toMap(Map.Entry::getKey, e -> {
|
||||
// List<Integer> scores = e.getValue();
|
||||
// int scoresSum = scores.stream().mapToInt(s -> s).sum();
|
||||
// return (float) scoresSum / scores.size();
|
||||
// }));
|
||||
return studentsScores.entrySet().stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, e -> {
|
||||
List<Integer> scores = e.getValue();
|
||||
int scoresSum = scores.stream().mapToInt(s -> s).sum();
|
||||
return (float) scoresSum / scores.size();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.util.Map;
|
||||
|
||||
public interface CharFrequency {
|
||||
|
||||
// Возвращает частоту каждого символа в тексте.
|
||||
// Иными словами, считает, сколько раз встречается тот или иной символ
|
||||
Map<Character, Integer> getSortedCharFrequency(String text);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import java.util.Map;
|
||||
|
||||
public interface WordGroup {
|
||||
|
||||
// Группирует слова в списки по длине.
|
||||
// Слова одинаковой длины попадают в один список, другой длинны - в другой список.
|
||||
// В Map'е ключ - длина слов в списке, значение - список слов
|
||||
Map<Integer, List<String>> groupWordsByLength(String text);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user