Skip to content

Commit 757171a

Browse files
committed
lab7
1 parent 75aa216 commit 757171a

File tree

68 files changed

+396
-249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+396
-249
lines changed

programming/sem2/lab5_v2/client/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
<version>1.0</version>
1818
<scope>compile</scope>
1919
</dependency>
20+
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
21+
<dependency>
22+
<groupId>org.openjfx</groupId>
23+
<artifactId>javafx</artifactId>
24+
<version>17</version>
25+
<type>pom</type>
26+
</dependency>
2027
</dependencies>
2128

2229
<artifactId>client</artifactId>
@@ -31,6 +38,14 @@
3138
</resources>
3239

3340
<plugins>
41+
<plugin>
42+
<groupId>org.openjfx</groupId>
43+
<artifactId>javafx-maven-plugin</artifactId>
44+
<version>0.0.8</version>
45+
<configuration>
46+
<mainClass>ui.RegisterLayout</mainClass>
47+
</configuration>
48+
</plugin>
3449
<plugin>
3550
<groupId>org.apache.maven.plugins</groupId>
3651
<artifactId>maven-jar-plugin</artifactId>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package commands.implementations;
2+
3+
import commands.BasicCommand;
4+
import core.Engine;
5+
6+
import java.util.HashMap;
7+
import java.util.function.Consumer;
8+
9+
public class RemoveAllByStandardOfLiving extends BasicCommand {
10+
public RemoveAllByStandardOfLiving(Consumer<HashMap<String,String>> outHandler){
11+
super("remove_all_by_standard_of_living", "Removes all cities with specified standard of life", outHandler);
12+
}
13+
14+
@Override
15+
public final void execute(HashMap<String, String> args, Engine engine) throws Exception{
16+
engine.networkManager.send(
17+
new shared.objects.NetworkRequestDTO(
18+
"remove_all_by_standard_of_living",
19+
args
20+
)
21+
);
22+
this.getOutHandler().accept(
23+
engine.networkManager.receive().result()
24+
);
25+
}
26+
}

programming/sem2/lab5_v2/client/src/commands/implementations/Save.java renamed to programming/sem2/lab5_v2/client/src/commands/implementations/RemoveById.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package commands.implementations;
22

3+
34
import commands.BasicCommand;
45
import core.Engine;
5-
import shared.objects.NetworkRequestDTO;
66

77
import java.util.HashMap;
88
import java.util.function.Consumer;
99

10-
public class Save extends BasicCommand {
11-
public Save(Consumer<HashMap<String,String>> outHandler){
12-
super("save", "saves collection to CSV file.", outHandler);
10+
public class RemoveById extends BasicCommand {
11+
public RemoveById(Consumer<HashMap<String,String>> outHandler){
12+
super("remove_by_id", "Clears all information about collection.", outHandler);
1313
}
1414

1515
@Override
1616
public final void execute(HashMap<String, String> args, Engine engine) throws Exception{
1717
engine.networkManager.send(
18-
new NetworkRequestDTO(
19-
"save",
18+
new shared.objects.NetworkRequestDTO(
19+
"remove_by_id",
2020
args
2121
)
2222
);
2323
this.getOutHandler().accept(
2424
engine.networkManager.receive().result()
2525
);
2626
}
27-
}
27+
}

programming/sem2/lab5_v2/client/src/commands/implementations/Load.java renamed to programming/sem2/lab5_v2/client/src/commands/implementations/RemoveFirst.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22

33
import commands.BasicCommand;
44
import core.Engine;
5-
import shared.objects.NetworkRequestDTO;
65

76
import java.util.HashMap;
87
import java.util.function.Consumer;
98

10-
public class Load extends BasicCommand {
11-
public Load(Consumer<HashMap<String,String>> outHandler){
12-
super("load", "loads collection from CSV file.", outHandler);
9+
public class RemoveFirst extends BasicCommand {
10+
public RemoveFirst(Consumer<HashMap<String,String>> outHandler){
11+
super("remove_first", "Removes first element from collection.", outHandler);
1312
}
1413

1514
@Override
1615
public final void execute(HashMap<String, String> args, Engine engine) throws Exception{
1716
engine.networkManager.send(
18-
new NetworkRequestDTO(
19-
"load",
17+
new shared.objects.NetworkRequestDTO(
18+
"remove_first",
2019
args
2120
)
2221
);

programming/sem2/lab5_v2/client/src/core/Engine.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public final class Engine {
2626
private final BasicCommand[] commands = {
2727
new Help(printer), new Add(printer), new Info(printer),
2828
new Clear(printer), new Exit(), new Show(printer),
29-
new Update(printer), new Execute(printer), new Save(printer),
29+
new Update(printer), new Execute(printer),
3030
new AvgOfMetersAboveSea(printer), new FilterStartsWithName(printer),
31-
new AddIfMax(printer), new RemoveGreater(printer), new Load(printer),
32-
new Register(printer)
31+
new AddIfMax(printer), new RemoveGreater(printer), new RemoveById(printer),
32+
new Register(printer), new RemoveFirst(printer), new RemoveAllByStandardOfLiving(printer)
3333
};
3434

3535
private final HashMap<String, BasicCommand> commandsHashMap = new HashMap<>();
@@ -77,6 +77,8 @@ public BasicCommand[] getCommands() {
7777
* @param args аргументы команды
7878
*/
7979
public void runCommand(String commandName, HashMap<String, String> args) {
80+
if (commandName.isEmpty()) return;
81+
8082
BasicCommand command = this.commandsHashMap.get(commandName);
8183

8284
if (command == null) {

programming/sem2/lab5_v2/client/src/script

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
register -login 1 -password 2
2+
13
add -name city1 -area 100 -population 1000 -metersAboveSeaLevel 0 -login 1 -password 2
24
2
35
2
@@ -7,4 +9,8 @@ test name
79
01.01.1971
810
OCEANIC
911
JUNTA
10-
HIGH
12+
HIGH
13+
14+
show -login 1 -password 2
15+
16+
remove_first -login 1 -password 2

programming/sem2/lab5_v2/client/target/classes/commands/implementations/Load.class renamed to programming/sem2/lab5_v2/client/target/classes/commands/implementations/RemoveById.class

1.64 KB
Binary file not shown.

programming/sem2/lab5_v2/client/target/classes/commands/implementations/Save.class renamed to programming/sem2/lab5_v2/client/target/classes/commands/implementations/RemoveFirst.class

1.64 KB
Binary file not shown.
152 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)