diff --git a/src/History.java b/src/History.java new file mode 100644 index 0000000..fcd9b7c --- /dev/null +++ b/src/History.java @@ -0,0 +1,16 @@ +import java.util.*; + +public class History { + private Total total; + private List value = new ArrayList<>(); + public void updatePayment(int payment) { + this.value.add(0, payment); + total.updateHistory(value); + } + public History(Total total) { + this.total = total; + } + public List getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/POS.java b/src/POS.java new file mode 100644 index 0000000..decefac --- /dev/null +++ b/src/POS.java @@ -0,0 +1,29 @@ +import java.util.*; + +public class POS { + private Points points; + private Total total; + private History history; + private Payment payment; + public POS() { + points = new Points(); + total = new Total(); + history = new History(total); + payment = new Payment(points,history); + } + public void purchase(int x) { + this.payment.purchase(x); + } + public int getTotal() { + return total.getValue(); + } + public int getPayment() { + return payment.getValue(); + } + public List getHistory() { + return history.getValue(); + } + public int getPoints() { + return points.getValue(); + } +} \ No newline at end of file diff --git a/src/Payment.java b/src/Payment.java new file mode 100644 index 0000000..b5b6be6 --- /dev/null +++ b/src/Payment.java @@ -0,0 +1,19 @@ +import java.util.*; + +public class Payment { + private Points points; + private History history; + private int value; + public Payment(Points points, History history) { + this.points = points; + this.history = history; + } + public void purchase(int x) { + this.value = x; + points.updatePayment(value); + history.updatePayment(value); + } + public int getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/Points.java b/src/Points.java new file mode 100644 index 0000000..c776197 --- /dev/null +++ b/src/Points.java @@ -0,0 +1,11 @@ +import java.util.*; + +public class Points { + private int value; + public void updatePayment(int payment) { + value = (int)Math.floor((payment*0.05)); + } + public int getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/Total.java b/src/Total.java new file mode 100644 index 0000000..27996b5 --- /dev/null +++ b/src/Total.java @@ -0,0 +1,15 @@ +import java.util.*; + +public class Total { + private int value; + public void updateHistory(List history) { + Integer temp_sum1 = 0; + for (Integer x: history) { + temp_sum1 += x; + } + value = temp_sum1; + } + public int getValue() { + return value; + } +} \ No newline at end of file