Advertisement
TsetsoP

clothes

Oct 28th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.93 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Clothes {
  4. private String clotheType, clotheSize, clotheBrand, clotheColor, clotheSeason, clotheGender;
  5. private double clothePrice;
  6. public static ArrayList<Clothes> clothesStorage = new ArrayList<>();
  7.  
  8. static {
  9. clothesStorage.add(new Clothes("Анцунг", "XS", "Flair", "светло-сив", 50, "пролет, есен", "Мъжко"));
  10. clothesStorage.add(new Clothes("Анцунг", "S", "ZARA", "червен", 40, "пролет", "Мъжко"));
  11. clothesStorage.add(new Clothes("Анцунг", "M", "Flair", "син", 30, "пролет, есен", "Мъжко"));
  12. clothesStorage.add(new Clothes("Анцунг", "L", "HM", "бял", 35, "пролет, есен, зима", "Мъжко"));
  13. clothesStorage.add(new Clothes("Анцунг", "L", "Nike", "черен", 25, "пролет, есен", "Дамско"));
  14. clothesStorage.add(new Clothes("Анцунг", "XL", "Flair", "бял", 50, "пролет, есен", "Дамско"));
  15. clothesStorage.add(new Clothes("Анцунг", "L", "Nike", "зелен", 35, "пролет, есен, зима", "Дамско"));
  16. clothesStorage.add(new Clothes("Анцунг", "XL", "Flair", "бордо", 35, "пролет, есен, зима", "Дамско"));
  17.  
  18. clothesStorage.add(new Clothes("Тениска", "L", "Puma", "сив", 25, "лято", "Мъжко"));
  19. clothesStorage.add(new Clothes("Тениска", "XL", "HM", "сив", 50, "лято", "Мъжко"));
  20. clothesStorage.add(new Clothes("Тениска", "S", "Lacoste", "жълт", 30, "лято", "Мъжко"));
  21. clothesStorage.add(new Clothes("Тениска", "XS", "Gucci", "син", 50, "лято", "Мъжко"));
  22. clothesStorage.add(new Clothes("Тениска", "M", "Tom Tailor", "циан", 20, "лято", "Дамско"));
  23. clothesStorage.add(new Clothes("Тениска", "L", "Gucci", "зелен", 17, "лято", "Дамско"));
  24. clothesStorage.add(new Clothes("Тениска", "M", "LCW", "циан", 20, "лято", "Дамско"));
  25. clothesStorage.add(new Clothes("Тениска", "XS", "Nike", "кафяв", 25, "лято", "Дамско"));
  26.  
  27. clothesStorage.add(new Clothes("Суичър", "L", "LCW", "син", 35, "есен", "Мъжко"));
  28. clothesStorage.add(new Clothes("Суичър", "L", "Lacoste", "кафяв", 65, "пролет, есен, зима", "Мъжко"));
  29. clothesStorage.add(new Clothes("Суичър", "M", "Adidas", "черен", 35, "есен", "Мъжко"));
  30. clothesStorage.add(new Clothes("Суичър", "XL", "Puma", "червен", 45, "есен", "Мъжко"));
  31. clothesStorage.add(new Clothes("Суичър", "S", "Nike", "розов", 50, "пролет, есен", "Дамско"));
  32. clothesStorage.add(new Clothes("Суичър", "M", "Adidas", "бежов", 25, "пролет, есен", "Дамско"));
  33. clothesStorage.add(new Clothes("Суичър", "XL", "Nike", "светло-сив", 50, "есен", "Дамско"));
  34. clothesStorage.add(new Clothes("Суичър", "L", "Puma", "бял", 43, "лято, есен", "Дамско"));
  35.  
  36. clothesStorage.add(new Clothes("Дънки", "S", "HM", "светло-сив", 44, "пролет, есен", "Мъжко"));
  37. clothesStorage.add(new Clothes("Дънки", "XL", "LCW", "черен", 30, "пролет, есен", "Мъжко"));
  38. clothesStorage.add(new Clothes("Дънки", "L", "ZARA", "бежов", 45, "пролет", "Мъжко"));
  39. clothesStorage.add(new Clothes("Дънки", "L", "LCW", "син", 30, "пролет, есен", "Мъжко"));
  40. clothesStorage.add(new Clothes("Дънки", "M", "HM", "тъмно-син", 35, "пролет", "Дамско"));
  41. clothesStorage.add(new Clothes("Дънки", "XS", "Adidas", "син", 50, "пролет", "Дамско"));
  42. clothesStorage.add(new Clothes("Дънки", "S", "Tom Tailor", "тъмно-сив", 35, "пролет", "Дамско"));
  43. clothesStorage.add(new Clothes("Дънки", "XS", "Adidas", "син", 50, "пролет", "Дамско"));
  44. }
  45.  
  46. public Clothes(String clotheType, String clotheSize, String clotheBrand, String clotheColor, double clothePrice, String clotheSeason, String clotheGender) {
  47. this.clotheType = clotheType;
  48. this.clotheSize = clotheSize;
  49. this.clotheBrand = clotheBrand;
  50. this.clotheColor = clotheColor;
  51. this.clothePrice = clothePrice;
  52. this.clotheSeason = clotheSeason;
  53. this.clotheGender = clotheGender;
  54. }
  55.  
  56. public Clothes(){
  57.  
  58. }
  59.  
  60. public String getClotheType() {
  61. return clotheType;
  62. }
  63.  
  64. public void setClotheType(String clotheType) {
  65. this.clotheType = clotheType;
  66. }
  67.  
  68. public String getClotheSize() {
  69. return clotheSize;
  70. }
  71.  
  72. public void setClotheSize(String clotheSize) {
  73. this.clotheSize = clotheSize;
  74. }
  75.  
  76. public String getClotheBrand() {
  77. return clotheBrand;
  78. }
  79.  
  80. public void setClotheBrand(String clotheBrand) {
  81. this.clotheBrand = clotheBrand;
  82. }
  83.  
  84. public String getClotheGender() {
  85. return clotheGender;
  86. }
  87.  
  88. public void setClotheGender(String clotheGender) {
  89. this.clotheGender = clotheGender;
  90. }
  91.  
  92. public static ArrayList<Clothes> getClothesStorage() {
  93. return clothesStorage;
  94. }
  95.  
  96. public static void setClothesStorage(ArrayList<Clothes> clothesStorage) {
  97. Clothes.clothesStorage = clothesStorage;
  98. }
  99.  
  100. public void setClothePrice(double clothePrice) {
  101. this.clothePrice = clothePrice;
  102. }
  103.  
  104. public String getClotheColor() {
  105. return clotheColor;
  106. }
  107.  
  108. public void setClotheColor(String clotheColor) {
  109. this.clotheColor = clotheColor;
  110. }
  111.  
  112. public double getClothePrice() {
  113. return clothePrice;
  114. }
  115.  
  116. public String getClotheSeason() {
  117. return clotheSeason;
  118. }
  119.  
  120. public void setClotheSeason(String clotheSeason) {
  121. this.clotheSeason = clotheSeason;
  122. }
  123.  
  124. public void getAllInfo() {
  125. System.out.println("---------------------");
  126. System.out.println("Вид : " + this.clotheType);
  127. System.out.println("Размер : " + this.clotheSize);
  128. System.out.println("Бранд : " + this.clotheBrand);
  129. System.out.println("Цвят: " + this.clotheColor);
  130. System.out.println("Цена : " + this.clothePrice + " лева");
  131. System.out.println("Сезон : " + this.clotheSeason);
  132. System.out.println("---------------------");
  133. }
  134.  
  135. public static void getClothesType(String desiredType, String desiredGender) {
  136. boolean bType = true;
  137. for (Clothes cl : clothesStorage) {
  138. if (cl.clotheType.equalsIgnoreCase(desiredType) && cl.clotheGender.equalsIgnoreCase(desiredGender)) {
  139. cl.getAllInfo();
  140. bType = false;
  141.  
  142. }
  143. }
  144. if (bType==true) { //If-a във for-а не се изпълнява и bType остава true
  145. System.out.println("Няма такъв вид дрехи");
  146. }
  147. }
  148.  
  149. public static void getClothesSize(String desiredSize, String desiredGender) {
  150. boolean bSize = true;
  151. for (Clothes cl : clothesStorage) {
  152. if (cl.clotheSize.equalsIgnoreCase(desiredSize) && cl.clotheGender.equalsIgnoreCase(desiredGender)) {
  153. cl.getAllInfo();
  154. bSize = false;
  155. }
  156.  
  157. }
  158. if (bSize) {
  159. System.out.println("Няма такъв размер дрехи");
  160. }
  161. }
  162.  
  163. public static void getClothesBrand(String desiredBrand, String desiredGender) {
  164. boolean bBrand = true;
  165. for (Clothes cl : clothesStorage) {
  166. if (cl.clotheBrand.equalsIgnoreCase(desiredBrand) && cl.clotheGender.equalsIgnoreCase(desiredGender)) {
  167. cl.getAllInfo();
  168. bBrand = false;
  169. }
  170.  
  171. }
  172. if (bBrand) {
  173. System.out.println("Няма такъв бранд дрехи");
  174. }
  175. }
  176.  
  177. public static void getClothesColor(String desiredColor, String desiredGender) {
  178. boolean bColor = true;
  179. for (Clothes cl : clothesStorage) {
  180. if (cl.clotheColor.equalsIgnoreCase(desiredColor) && cl.clotheGender.equalsIgnoreCase(desiredGender)) {
  181. cl.getAllInfo();
  182. bColor = false;
  183. }
  184.  
  185. }
  186. if (bColor) {
  187. System.out.println("Няма такъв цвят дрехи");
  188. }
  189. }
  190.  
  191. public static void getClothesPrice(double desiredPrice, String desiredGender) {
  192. boolean bPrice = true;
  193. for (Clothes cl : clothesStorage) {
  194. if (cl.clothePrice <= desiredPrice && cl.clotheGender.equalsIgnoreCase(desiredGender)) {
  195. cl.getAllInfo();
  196. bPrice = false;
  197. }
  198. }
  199. if (bPrice) {
  200. System.out.println("Няма дреха за такава цени");
  201. }
  202. }
  203.  
  204. public static void getClothesSeason(String desiredSeason, String desiredGender) {
  205. boolean bSeason = true;
  206. for (Clothes cl : clothesStorage) {
  207. if (cl.clotheSeason.contains(desiredSeason) && cl.clotheGender.equalsIgnoreCase(desiredGender)) { //equalsIgnoreCase - показва само пролет/само есен
  208. cl.getAllInfo();
  209. bSeason = false;
  210. }
  211.  
  212. }
  213. if (bSeason) {
  214. System.out.println("Няма дрехи за такъв сезон");
  215. }
  216. }
  217.  
  218. public static void getAllClothes(String desiredGender) {
  219. for (Clothes cl : clothesStorage) {
  220. if (cl.clotheGender.equalsIgnoreCase(desiredGender)) {
  221. cl.getAllInfo();
  222.  
  223. }
  224. }
  225. }
  226.  
  227. }
  228.  
  229.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement