From 226feb7c4621c849562ccbfa11bedb253864b9b5 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Tue, 27 Feb 2024 21:33:04 +0800 Subject: [PATCH] calculate change --- .../tech/iBeans/POSware/Lite/payment.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/java/tech/iBeans/POSware/Lite/payment.java b/src/main/java/tech/iBeans/POSware/Lite/payment.java index 8d9e220..0ff7490 100644 --- a/src/main/java/tech/iBeans/POSware/Lite/payment.java +++ b/src/main/java/tech/iBeans/POSware/Lite/payment.java @@ -4,4 +4,46 @@ package tech.iBeans.POSware.Lite; import java.util.*; import java.math.*; -public class payment{}; \ No newline at end of file +public class payment{ + public static Float total = null; + public static Float change = null; + public static Float in = null; + + public static void init() { + /* Set up the payment. */ + change = (float) 0; + in = (float) 0; + }; + + public static Float calculate() { + /* Calculate the change. + * + * Returns: (float) the calculated change + */ + + + if (total > in) {return (null);}; // Do not calculate a smaller change. + change = in - total; + return(change); + }; + + public static Float calculate(float TOTAL, float IN) { + /* Calculate the change from a provided total and input. + * + * Returns: (float) the calculated change + */ + + total = TOTAL; + in = IN; + + return(calculate()); + }; + + public static void log() { + /* Log the payment. + */ + + // TODO add payment processing here. + }; + +}; \ No newline at end of file