12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Created by leon on 1/10/18.
  3. */
  4. public class MainApplication {
  5. public static void main(String[] args) {
  6. System.out.println("This is a quick inventory demo!");
  7. Inventory starkStuff = new Inventory();
  8. System.out.println("We can create a new inventory for Rickon Stark's new store, Stark Stuff!");
  9. starkStuff.addItem(3.00f, 9, "direwolf collar");
  10. System.out.println("We added an invetory item called " + starkStuff.getItem("direwolf collar").getID());
  11. System.out.println("The price is: " + starkStuff.getPrice("direwolf collar"));
  12. System.out.println("The quanitity is: " + starkStuff.getOnHandQuantity("direwolf collar"));
  13. starkStuff.addItem(2.50f, 5, "direwolf treat");
  14. starkStuff.addItem(2.99f, 6, "winterfell snowglobe");
  15. System.out.println(String.format("There are also %d direwolf treats that cost $%.2f.",
  16. starkStuff.getOnHandQuantity("direwolf treat"), starkStuff.getPrice("direwolf treat")));
  17. System.out.println(String.format("There are also %d winterfell snowglobes that cost $%.2f.",
  18. starkStuff.getOnHandQuantity("winterfell snowglobe"), starkStuff.getPrice("winterfell snowglobe")));
  19. starkStuff.updatePrice("winterfell snowglobe", 199.99f);
  20. System.out.println("But wait!");
  21. System.out.println("After Jon Snow returned to Winterfell, the demand for winterfell snowglobes shot way up!");
  22. System.out.println("Rickon decides to up the price. (sadly, he must do this from beyond the grave)");
  23. System.out.println(String.format("The new price of winterfell snowglobes is: $%.2f", starkStuff.getPrice("winterfell snowglobe")));
  24. starkStuff.removeUnits("direwolf treat", 3);
  25. System.out.println("With Jon Snow's direwolf Ghost around, the direwolf treats are selling fast.");
  26. System.out.println(String.format("The new on hand quantity for direwolf treats is: %d", starkStuff.getOnHandQuantity("direwolf treat")));
  27. starkStuff.addUnits("winterfell snowglobe", 15);
  28. System.out.println("Luckily there is a new shipment of winterfell snowglobe.");
  29. System.out.println(String.format("The new on hand quantity for winterfell snowglobes is: %d", starkStuff.getOnHandQuantity("winterfell snowglobe")));
  30. double inVal = starkStuff.getInventoryValue();
  31. System.out.println(String.format("Now, the total value of the late Rickon Stark's inventory is: $%.2f", inVal));
  32. }
  33. }