Paar Kommentare, sowie Name u. Mrt. Nummer der Gruppe
This commit is contained in:
parent
0e27974ea4
commit
e07514241f
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,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" project-jdk-name="16" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="16" project-jdk-type="JavaSDK" />
|
||||
</project>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
|
@ -64,7 +64,7 @@ public class AddressBook extends AbstractBehavior<AddressBook.Message> {
|
|||
Random random = new Random();
|
||||
int index = random.nextInt(customers.size());
|
||||
ActorRef<Customer.Message> addressOf = customers.get(index);
|
||||
getContext().getLog().info("{} asked for an address CAR: {} ", msg.nameFragender, msg.truckReference.path().name());
|
||||
getContext().getLog().info("{} hat nach einer Addresse gefragt CAR: {} ", msg.nameFragender, msg.truckReference.path().name());
|
||||
msg.fragender.tell(new Customer.AddressMessage(addressOf, msg.truckReference));
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
|
||||
/*
|
||||
Martrikelnummer der Gruppenmitglieder: Olha Grubryn (), Egor Rutkowski(225064), Nikola Kramaric (238498), Dennis Ruppel (238503)
|
||||
*/
|
||||
package com.example;
|
||||
|
||||
import akka.actor.typed.ActorSystem;
|
||||
|
|
|
@ -51,6 +51,7 @@ public class DeliveryCar extends AbstractBehavior<DeliveryCar.Message> {
|
|||
.build();
|
||||
}
|
||||
|
||||
//Nachricht, um Pakete zu beladen von DistributionCenter z.B.
|
||||
private Behavior<Message> onLoadMessage(LoadMessage msg) {
|
||||
pakete.addAll(msg.pakete);
|
||||
getContext().getLog().info("Laden: {} Pakete wurden in den LKW geladen.", msg.pakete.size());
|
||||
|
@ -58,6 +59,8 @@ public class DeliveryCar extends AbstractBehavior<DeliveryCar.Message> {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
//Die Nachricht, die den Paket, vom Kunden abholt und in den Wagen lädt
|
||||
private Behavior<Message> onPickupResponse(PickupResponse rsp) {
|
||||
if (rsp.paket != null && rsp.paket.inhalt != null && pakete.size() < maxCapacity) {
|
||||
pakete.add(rsp.paket);
|
||||
|
@ -67,6 +70,7 @@ public class DeliveryCar extends AbstractBehavior<DeliveryCar.Message> {
|
|||
return this;
|
||||
}
|
||||
|
||||
//Prüft, ob der Wagen schon alle Addressen durchgegangen ist und geht zum Verteilerzentrum, sonst. geht dieser seine Route weiter
|
||||
private Behavior<Message> onCheckStop(CheckStop stop) {
|
||||
if (globalIndex >= route.size()) {
|
||||
getContext().getLog().info("Rückkehr: Der LKW kehrt zum Verteilzentrum zurück mit {} Paketen.", pakete.size());
|
||||
|
@ -86,21 +90,26 @@ public class DeliveryCar extends AbstractBehavior<DeliveryCar.Message> {
|
|||
return this;
|
||||
}
|
||||
|
||||
//Methode, um die Autos zu "starten"
|
||||
private Behavior<Message> onStartRoute(StartRoute msg) {
|
||||
globalIndex = 0;
|
||||
scheduleNextStopCheck(Duration.ofSeconds(3)); // Start checking the first stop after 3 seconds
|
||||
return this;
|
||||
}
|
||||
|
||||
//
|
||||
private Behavior<Message> onClear(Clear clear) {
|
||||
pakete.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
//Sendet eine Nachricht an Customer bzw. an einen Addressaten, wo der Wagen steht, und fragt ob ein Paket von denen geliefert werden soll
|
||||
private void sendPickupMessage(ActorRef<Customer.Message> customer) {
|
||||
customer.tell(new Customer.PickUpMessage(getContext().getSelf(), "Der LKW kann das Paket abholen."));
|
||||
}
|
||||
|
||||
|
||||
//Liefert Paket aus, die im Wagen ist
|
||||
private void deliverPackages(ActorRef<Customer.Message> customer) {
|
||||
pakete.removeIf(paket -> {
|
||||
if (paket.empfaenger.equals(customer)) {
|
||||
|
@ -111,6 +120,7 @@ public class DeliveryCar extends AbstractBehavior<DeliveryCar.Message> {
|
|||
});
|
||||
}
|
||||
|
||||
//Private Methode für den Timer
|
||||
private void scheduleNextStopCheck(Duration duration) {
|
||||
timers.startSingleTimer(new CheckStop(), duration);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue