mirror of
https://github.com/lucasroyerdev/stock-pignon.git
synced 2026-05-10 11:02:26 +00:00
feat: add online editor, work in progress
This commit is contained in:
@@ -8,10 +8,14 @@ public class CartManager {
|
||||
// Unified and global list for whole application
|
||||
private static final List<CartItem> items = new ArrayList<>();
|
||||
|
||||
// Private constructor: utility class, it should not be instantiated
|
||||
/**
|
||||
* Private constructor: utility class, it should not be instantiated
|
||||
*/
|
||||
private CartManager() {}
|
||||
|
||||
// Returns the direct reference to the list to save memory on older devices
|
||||
/**
|
||||
* Returns the direct reference to the list to save memory on older devices
|
||||
*/
|
||||
public static List<CartItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
@@ -25,7 +29,9 @@ public class CartManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Logic for adding, updating or removing items based on quantity, prevents duplicate entries
|
||||
/**
|
||||
* Logic for adding, updating or removing items based on quantity, prevents duplicate entries
|
||||
*/
|
||||
public static void addOrUpdateItem(String name, int minPrice, int maxPrice, int quantity, String imageFile) {
|
||||
CartItem current = getItemByName(name);
|
||||
|
||||
@@ -40,20 +46,27 @@ public class CartManager {
|
||||
}
|
||||
}
|
||||
|
||||
// Range-based pricing
|
||||
|
||||
/**
|
||||
* Range-based pricing
|
||||
*/
|
||||
public static int getGlobalTotalMin() {
|
||||
int total = 0;
|
||||
for (CartItem item : items) total += item.getTotalMin();
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Range-based pricing
|
||||
*/
|
||||
public static int getGlobalTotalMax() {
|
||||
int total = 0;
|
||||
for (CartItem item : items) total += item.getTotalMax();
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove item from cart
|
||||
*/
|
||||
public static void clear() {
|
||||
items.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user