Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. public class ProductInfo {
  2. private String[] name = new String[4];
  3. private String[] linkImg1 = new String[4];
  4. private String[] linkImg2 = new String[4];
  5. private String[] linkImg3 = new String[4];
  6. private String[] cpu = new String[4];
  7. private String[] gpu = new String[4];
  8. private String[] ram = new String[4];
  9. private String[] storage = new String[4];
  10. private String[] operativeSystem = new String[4];
  11. public String[] ID = new String[4];
  12. private int[] price = new int[4];
  13. public int contProd = 0;
  14.  
  15. public void createProduct(String name, int price, String linkImg1, String linkImg2, String linkImg3) {
  16. if(contProd<4) {
  17. ID[contProd] = Integer.toString(contProd);
  18. this.name[contProd] = name;
  19. this.price[contProd] = price;
  20. this.linkImg1[contProd] = linkImg1;
  21. this.linkImg2[contProd] = linkImg2;
  22. this.linkImg3[contProd] = linkImg3;
  23. }
  24.  
  25. }
  26.  
  27. public void addProductSpecs(String cpu, String gpu, String ram, String storage, String operativeSystem) {
  28. if(contProd<4) {
  29. this.cpu[contProd] = cpu;
  30. this.gpu[contProd] = gpu;
  31. this.ram[contProd] = ram;
  32. this.storage[contProd] = storage;
  33. this.operativeSystem[contProd] = operativeSystem;
  34. }
  35. }
  36. /*
  37. public boolean checkName(String name) {
  38. for(int j=0; j<contProd; j++) {
  39. if(this.name[j].equals(name))
  40. return true;
  41. }
  42. return false;
  43. }*/
  44.  
  45. public String viewName(String ID) {
  46. for(int i=0; i<contProd; i++) {
  47. if(this.ID[i].equals(ID))
  48. return name[i];
  49. }
  50. return "Not found";
  51. }
  52.  
  53. public int viewPrice(String ID) {
  54. for(int i=0; i<contProd; i++) {
  55. if(this.ID[i].equals(ID))
  56. return price[i];
  57. }
  58. return 0;
  59. }
  60.  
  61.  
  62. public String viewLinkImg1(String ID) {
  63. for(int i=0; i<contProd; i++) {
  64. if(this.ID[i].equals(ID))
  65. return linkImg1[i];
  66. }
  67. return "Not found";
  68. }
  69.  
  70. public String viewLinkImg2(String ID) {
  71. for(int i=0; i<contProd; i++) {
  72. if(this.ID[i].equals(ID))
  73. return linkImg2[i];
  74. }
  75. return "Not found";
  76. }
  77.  
  78. public String viewLinkImg3(String ID) {
  79. for(int i=0; i<contProd; i++) {
  80. if(this.ID[i].equals(ID))
  81. return linkImg3[i];
  82. }
  83. return "Not found";
  84. }
  85.  
  86. public String viewCpu(String ID) {
  87. for(int i=0; i<contProd; i++) {
  88. if(this.ID[i].equals(ID))
  89. return cpu[i];
  90. }
  91. return "Not found";
  92. }
  93.  
  94. public String viewGpu(String ID) {
  95. for(int i=0; i<contProd; i++) {
  96. if(this.ID[i].equals(ID))
  97. return gpu[i];
  98. }
  99. return "Not found";
  100. }
  101.  
  102. public String viewRam(String ID) {
  103. for(int i=0; i<contProd; i++) {
  104. if(this.ID[i].equals(ID))
  105. return ram[i];
  106. }
  107. return "Not found";
  108. }
  109.  
  110. public String viewStorage(String ID) {
  111. for(int i=0; i<contProd; i++) {
  112. if(this.ID[i].equals(ID))
  113. return storage[i];
  114. }
  115. return "Not found";
  116. }
  117.  
  118. public String viewOperatiSystem(String ID) {
  119. for(int i=0; i<contProd; i++) {
  120. if(this.ID[i].equals(ID))
  121. return operativeSystem[i];
  122. }
  123. return "Not found";
  124. }
  125.  
  126.  
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement