Skip to content

Commit

Permalink
Fix small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoly Anischenko committed Dec 2, 2020
1 parent 915010a commit 273ab7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
28 changes: 8 additions & 20 deletions src/generator/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import generator.objects.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.time.LocalDate;
Expand Down Expand Up @@ -49,7 +48,7 @@ public class Generator {
private static Set<Integer> used_participants_id = new HashSet<>();

public static void main(String[] args) throws FileNotFoundException {
PrintWriter out = new PrintWriter(new File("test.sql"));
PrintWriter out = new PrintWriter("test.sql");

//generate random people
for (int iter = 0; iter < COUNT_OF_MENTORS + COUNT_OF_JUDGES; iter++) {
Expand All @@ -65,7 +64,7 @@ public static void main(String[] args) throws FileNotFoundException {

//generate platforms
for (int iter = 0; iter < COUNT_OF_PLATFORMS; iter++) {
Person randomPerson = selectRandomPerson();
Person randomPerson = getRandomElement(people);

while (random.nextInt(10) > 3) {
Phone.generate(randomPerson.person_id);
Expand Down Expand Up @@ -108,19 +107,19 @@ public static void main(String[] args) throws FileNotFoundException {

Set<Integer> curCases = new HashSet<>();
while (curCases.size() < cntCases) {
curCases.add(selectRandomCase().case_id);
curCases.add(getRandomElement(cases).case_id);
}

int cntPlatforms = random.nextInt(5) + 2;

Set<Integer> platforms = new HashSet<>();
while (platforms.size() < cntPlatforms) {
platforms.add(selectRandomPlatform().platform_id);
Set<Integer> curPlatforms = new HashSet<>();
while (curPlatforms.size() < cntPlatforms) {
curPlatforms.add(getRandomElement(platforms).platform_id);
}

Championship championship = Championship.generate(
new ArrayList<>(curCases),
new ArrayList<>(platforms)
new ArrayList<>(curPlatforms)
);

addScript(SMALL_SCRIPT_SEPARATOR);
Expand Down Expand Up @@ -247,6 +246,7 @@ public static void main(String[] args) throws FileNotFoundException {
projectCases = new ArrayList<>();
System.err.println("ERROR_BD_ERROR");
}

int maxPoints = cases.stream()
.filter(curCase -> projectCases.contains(curCase.case_id))
.mapToInt(curCase -> curCase.complexity).sum();
Expand Down Expand Up @@ -302,18 +302,6 @@ public static String getIntArray(List<Integer> array) {
return res.toString();
}

private static Person selectRandomPerson() {
return people.get(random.nextInt(people.size()));
}

private static Case selectRandomCase() {
return cases.get(random.nextInt(cases.size()));
}

private static Platform selectRandomPlatform() {
return platforms.get(random.nextInt(platforms.size()));
}

private static int selectRandomParticipant() {
while (true) {
int size = participants_id.size();
Expand Down
2 changes: 0 additions & 2 deletions src/generator/objects/Performance.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package generator.objects;

import generator.Generator;
import sun.misc.Perf;

import java.time.LocalDateTime;
import java.util.List;

public class Performance {
private static int cnt = 1;
Expand Down

0 comments on commit 273ab7e

Please sign in to comment.