Advertisement
ledafaze

Untitled

Mar 14th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. package gameStore;
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5. import java.util.concurrent.atomic.*;
  6.  
  7.  
  8. public class GameStoreApp {
  9.  
  10. static HashMap<LocalStores, HashMap<Games, AtomicInteger>> inStock = new HashMap<LocalStores, HashMap<Games, AtomicInteger>>();
  11. static HashMap<LocalStores, HashMap<Games, AtomicInteger>> rentedOut = new HashMap<LocalStores, HashMap<Games, AtomicInteger>>();
  12. static HashMap<LocalStores, HashMap<Games, AtomicInteger>> overDue = new HashMap<LocalStores, HashMap<Games, AtomicInteger>>();
  13. static HashMap<Games, AtomicInteger> stockMap = new HashMap<Games, AtomicInteger>();
  14. static HashMap<Games, AtomicInteger> rentedMap = new HashMap<Games, AtomicInteger>();
  15. static HashMap<Games, AtomicInteger> dueMap = new HashMap<Games, AtomicInteger>();
  16.  
  17. static void populateHashMaps(){
  18. goInStock();
  19. goOverDue();
  20. goRentedOut();
  21. }
  22.  
  23. public static void main(String[] args) {
  24. populateHashMaps();
  25. }
  26.  
  27. private static void goInStock() {
  28. try{
  29. Scanner in = new Scanner (new FileReader("inStockFile.txt"));
  30. try {
  31. String line = in.nextLine();
  32. while (in.hasNextLine()) {
  33. String[] fields = line.split("[\\t]");
  34. if (fields.length == 3) {
  35. addToInStockMap(new Games(fields[0]), new LocalStores(fields[1]), new AtomicInteger(Integer.parseInt(fields[2])));
  36. }
  37. line = in.nextLine();
  38. }
  39. }
  40. finally {
  41. in.close();
  42. }
  43. }
  44.  
  45. catch (Exception ex){
  46. System.out.println("In Stock File Exception error: " + ex);
  47. }
  48. }
  49.  
  50. private static void goRentedOut() {
  51. try{
  52. Scanner in = new Scanner (new FileReader("rentedOutFile.txt"));
  53. try {
  54. String line = in.nextLine();
  55. while (in.hasNextLine()) {
  56. String[] fields = line.split("[\\t]");
  57. if (fields.length == 3) {
  58. addToRentedOutMap(new Games(fields[0]), new LocalStores(fields[1]), new AtomicInteger(Integer.parseInt(fields[2])));
  59. }
  60. line = in.nextLine();
  61. }
  62. }
  63. finally {
  64. in.close();
  65. }
  66. }
  67.  
  68. catch (Exception ex){
  69. System.out.println("Rented Out File Exception error: " + ex);
  70. }
  71. }
  72.  
  73. private static void goOverDue() {
  74. try{
  75. Scanner in = new Scanner (new FileReader("overDueFile.txt"));
  76. try {
  77. String line = in.nextLine();
  78. while (in.hasNextLine()) {
  79. String[] fields = line.split("[\\t]");
  80. if (fields.length == 3) {
  81. addToOverDueMap(new Games(fields[0]), new LocalStores(fields[1]), new AtomicInteger(Integer.parseInt(fields[2])));
  82. }
  83. line = in.nextLine();
  84. }
  85. }
  86. finally {
  87. in.close();
  88. }
  89. }
  90.  
  91. catch (Exception ex){
  92. System.out.println("Over Due File Exception error: " + ex);
  93. }
  94. }
  95.  
  96. static void addToInStockMap (Games games, LocalStores store, AtomicInteger value){
  97. stockMap.put(games, value);
  98. inStock.put(store, stockMap);
  99. }
  100.  
  101. static void addToRentedOutMap (Games games, LocalStores store, AtomicInteger value){
  102. stockMap.put(games, value);
  103. inStock.put(store, rentedMap);
  104. }
  105.  
  106. static void addToOverDueMap (Games games, LocalStores store, AtomicInteger value){
  107. stockMap.put(games, value);
  108. inStock.put(store, dueMap);
  109. }
  110.  
  111. static void checkStock(){
  112. // new AtominInteger k = inStock.get(stockMap).get(AtomicInteger);
  113. // int ko = inStock.get(stockMap).get(AtomicInteger);
  114. // String ke = inStock.get(stockMap).get(LocalStores);
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement