diff --git a/AlgebraicDataflowArchitectureModel/src/experiment/push/History.java b/AlgebraicDataflowArchitectureModel/src/experiment/push/History.java new file mode 100644 index 0000000..0270b05 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/experiment/push/History.java @@ -0,0 +1,18 @@ +package experiment.push; + +import java.util.ArrayList; + +public class History { + private Total total; + private ArrayList history = new ArrayList(); + public void updatePayment(int payment) { + history.add(payment); + total.update(history); + } + public History(Total total) { + this.total = total; + } + public ArrayList getHistory() { + return history; + } +} diff --git a/AlgebraicDataflowArchitectureModel/src/experiment/push/Main.java b/AlgebraicDataflowArchitectureModel/src/experiment/push/Main.java new file mode 100644 index 0000000..3015614 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/experiment/push/Main.java @@ -0,0 +1,25 @@ +package experiment.push; + +import java.util.ArrayList; + +public class Main { + private Total total = new Total(); + private Points points = new Points(); + private History history = new History(total); + private Payment payment = new Payment(history,points); + public void purchase(int payment) { + this.payment.purchase(payment); + } + public int getTotal() { + return total.getTotal(); + } + public int getPayment() { + return payment.getPayment(); + } + public ArrayList getHistory() { + return history.getHistory(); + } + public int getPoints() { + return points.getPoints(); + } +} diff --git a/AlgebraicDataflowArchitectureModel/src/experiment/push/Payment.java b/AlgebraicDataflowArchitectureModel/src/experiment/push/Payment.java new file mode 100644 index 0000000..202ead9 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/experiment/push/Payment.java @@ -0,0 +1,18 @@ +package experiment.push; + +public class Payment { + private History history; + private Points points; + public Payment(History history, Points points) { + this.history = history; + this.points = points; + } + public void purchase(int payment) { + this.payment = payment; + history.update(payment); + points.update(payment); + } + public int getPayment() { + return payment; + } +} diff --git a/AlgebraicDataflowArchitectureModel/src/experiment/push/Points.java b/AlgebraicDataflowArchitectureModel/src/experiment/push/Points.java new file mode 100644 index 0000000..41a59c8 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/experiment/push/Points.java @@ -0,0 +1,11 @@ +package experiment.push; + +public class Points { + private int points; + public void updatePayment(int payment) { + points = (int)Math.floor((payment*0.05)); + } + public int getPoints() { + return points; + } +} diff --git a/AlgebraicDataflowArchitectureModel/src/experiment/push/Total.java b/AlgebraicDataflowArchitectureModel/src/experiment/push/Total.java new file mode 100644 index 0000000..25b5e24 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/experiment/push/Total.java @@ -0,0 +1,13 @@ +package experiment.push; + +import java.util.ArrayList; + +public class Total { + private int total; + public void updateHistory(ArrayList history) { + total = history.stream().mapToInt(x->x).sum(); + } + public int getTotal() { + return total; + } +}