Package com.ccprog3
Class UserSingleton
java.lang.Object
com.ccprog3.UserSingleton
- All Implemented Interfaces:
Serializable
,AutoCloseable
User class for the runtime instance
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCoffeeTruck
(CoffeeTruck coffeeTruck) Adds aCoffeeTruck
void
close()
Gets the prices of Coffee Types per fluid ounceGets the List of Coffee TrucksGets the prices ofEspresso
shots per fluid ouncestatic UserSingleton
Gets theUserSingleton
instanceGets the prices of Syrup Ingredients per fluid ounceGets the usernameLogs the user in (opens save file)void
removeCoffeeTruck
(int index) Removes aCoffeeTruck
void
setCoffeePrices
(Map<CoffeeType, Money> coffeePrices) Sets the prices of the given Coffee Types per fluid ouncevoid
setCoffeeTruckLocation
(String location, int index) Sets the newCoffeeTruck
locationvoid
setEspressoPrices
(Map<Espresso, Money> espressoPrices) Sets the prices of the givenEspresso
shots per fluid ouncevoid
setSyrupPrices
(Map<SyrupIngredient, Money> syrupPrices) Sets the prices of the given Syrup Ingredients per fluid ounce
-
Method Details
-
getInstance
-
getUsername
-
getCoffeeTrucks
Gets the List of Coffee Trucks- Returns:
- The List of Coffee Trucks
-
getCoffeePrices
Gets the prices of Coffee Types per fluid ounce- Returns:
- Map of Coffee Types and their prices
-
getEspressoPrices
-
getSyrupPrices
Gets the prices of Syrup Ingredients per fluid ounce- Returns:
- Map of Syrup Ingredients and their prices
-
setCoffeePrices
Sets the prices of the given Coffee Types per fluid ounce- Parameters:
coffeePrices
- Map of Coffee Types and their prices
-
setEspressoPrices
-
setSyrupPrices
Sets the prices of the given Syrup Ingredients per fluid ounce- Parameters:
syrupPrices
- Map of Syrup Ingredients and their prices- Throws:
IllegalArgumentException
- Cannot set a price for None
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
login
Logs the user in (opens save file)- Parameters:
username
- Username to log in with- Returns:
- User data
- Throws:
FileNotFoundException
- User not found
-
addCoffeeTruck
Adds aCoffeeTruck
- Parameters:
coffeeTruck
- TheCoffeeTruck
to add- Throws:
IllegalArgumentException
- Location is already occupied
-
removeCoffeeTruck
Removes aCoffeeTruck
- Parameters:
index
-CoffeeTruck
index- Throws:
ArrayIndexOutOfBoundsException
- Index out of boundsIndexOutOfBoundsException
-
setCoffeeTruckLocation
public void setCoffeeTruckLocation(String location, int index) throws IllegalArgumentException, IndexOutOfBoundsException Sets the newCoffeeTruck
location- Parameters:
location
- New locationindex
-CoffeeTruck
index- Throws:
ArrayIndexOutOfBoundsException
- Index out of boundsIllegalArgumentException
- Location is already occupiedIndexOutOfBoundsException
-