TsetsoP

CLOTHES STORE

Oct 24th, 2021 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.14 KB | None | 0 0
  1. //CLOTHES STORE
  2.  
  3. import java.util.*;
  4.  
  5. public class Clothes {
  6.     public String clotheStyle;
  7.     public String clotheSize;
  8.     private String clotheBrand;
  9.     private float clothePrice;
  10.     private String clotheSeason;
  11.     private static ArrayList<Clothes> clothesStorage = new ArrayList<>();
  12.  
  13.  
  14.     static  {
  15.         clothesStorage.add(new Clothes("Тениска","XL", "Gucci", 50, "Лято" ));
  16.         clothesStorage.add(new Clothes("Суичър","S", "Nike",50, "Есен" ));
  17.         clothesStorage.add(new Clothes("Анцунг","L", "Flair", 50,"Пролет, есен" ));
  18.         clothesStorage.add(new Clothes("Дънки","XS", "Adidas", 50,"Пролет" ));
  19.     }
  20.  
  21.     public Clothes(String clotheStyle, String clotheSize, String clotheBrand,float clothePrice,  String clotheSeason) {
  22.         this.clotheStyle = clotheStyle;
  23.         this.clotheSize = clotheSize;
  24.         this.clotheBrand = clotheBrand;
  25.         this.clothePrice = clothePrice;
  26.         this.clotheSeason = clotheSeason;
  27.     }
  28.  
  29.     public String getClotheStyle() {
  30.         return clotheStyle;
  31.     }
  32.  
  33.     public String getClotheSize() {
  34.         return clotheSize;
  35.     }
  36.  
  37.     public String getClotheBrand() {
  38.         return clotheBrand;
  39.     }
  40.  
  41.     public float getClothePrize() {
  42.         return clothePrice;
  43.    }
  44.  
  45.     public String getClotheSeason() {
  46.         return clotheSeason;
  47.     }
  48.  
  49.  
  50.     public void setClotheStyle(String clotheStyle) {this.clotheStyle = clotheStyle;
  51.     }
  52.     public void setClotheSize(String clotheSize) {this.clotheSize = clotheSize;
  53.     }
  54.     public void setClotheBrand(String clotheBrand) {this.clotheBrand = clotheBrand;
  55.     }
  56.     public void setClotheSeason(String clotheSeason) {this.clotheSeason = clotheSeason;
  57.     }
  58.  
  59.  
  60.       public void getAllInfo() {
  61.         System.out.println("Стил : " + this.clotheStyle);
  62.         System.out.println("Размер : " + this.clotheSize);
  63.         System.out.println("Бранд : " + this.clotheBrand);
  64.         System.out.println("Цена : " + this.clothePrice + "лева");
  65.         System.out.println("Сезон : " + this.clotheSeason);
  66.     }
  67.  
  68.     public static void getClothesStyle(String desiredStyle) {
  69.         boolean bStyle = true;
  70.         for (Clothes cl : clothesStorage) {
  71.             if (cl.clotheStyle.equalsIgnoreCase(desiredStyle)) {
  72.                 cl.getAllInfo();
  73.                 bStyle = false;
  74.             }
  75.  
  76.         }
  77.         if(bStyle){
  78.             System.out.println("Няма такъв стил ");
  79.         }
  80.     }
  81.  
  82.         public static void getClothesSize (String desiredSize){
  83.         boolean bSize = true;
  84.             for (Clothes cl : clothesStorage) {
  85.                 if (cl.clotheSize.equalsIgnoreCase(desiredSize)) {
  86.                     cl.getAllInfo();
  87.                     bSize = false;
  88.                 }
  89.  
  90.             }
  91.             if(bSize){
  92.                 System.out.println("Няма такъв размер");
  93.             }
  94.         }
  95.       public static void getClothesBrand (String desiredBrand){
  96.           boolean bBrand = true;
  97.           for (Clothes cl : clothesStorage) {
  98.               if (cl.clotheBrand.equalsIgnoreCase(desiredBrand)) {
  99.                   cl.getAllInfo();
  100.                   bBrand = false;
  101.               }
  102.  
  103.           }
  104.           if(bBrand){
  105.               System.out.println("Няма такъв бранд");
  106.           }
  107.     }
  108.     public static void getClothesPrice (float desiredPrice){
  109.         boolean bPrice = true;
  110.         for (Clothes cl : clothesStorage) {
  111.             if (cl.clothePrice == desiredPrice) {
  112.                 cl.getAllInfo();
  113.                 bPrice = false;
  114.             }
  115.         }
  116.         if(bPrice){
  117.             System.out.println("Няма за такава цена");
  118.         }
  119.     }
  120.  
  121.  
  122.     public static void getClothesSeason (String desiredSeason){
  123.         boolean bSeason = true;
  124.         for (Clothes cl : clothesStorage) {
  125.             if (cl.clotheSeason.equalsIgnoreCase(desiredSeason)) {
  126.                 cl.getAllInfo();
  127.                 bSeason = false;
  128.             }
  129.  
  130.         }
  131.         if(bSeason){
  132.             System.out.println("Няма дреха за такъв сезон");
  133.         }
  134.     }
  135. }
  136. ====================================================================
  137. //MAIN
  138.  
  139. import java.util.*;
  140. public class App {
  141.  Scanner scan = new Scanner(System.in);
  142.  
  143.     public static void main(String[] args) {
  144.         Scanner scan = new Scanner(System.in);
  145.  
  146.         String input = "";
  147.         while (!input.equalsIgnoreCase("стоп")) {
  148.             System.out.println(" 1. Търсене по стил " +
  149.                     "\n 2. Търсене по размер " +
  150.                     "\n 3. Търсене по бранд" +
  151.                     "\n 4. Търсене по сезон");
  152.              input = scan.nextLine();
  153.             switch (input) {
  154.                 case "1":
  155.                     System.out.println("Какъв стил дрехи търсите?");
  156.                     String desiredStyle = scan.nextLine();
  157.                     Clothes.getClothesStyle(desiredStyle);
  158.                     break;
  159.  
  160.  
  161.                 case "2":
  162.                     System.out.println("Какъв размер търсите?");
  163.                     String desiredSize = scan.nextLine();
  164.                     Clothes.getClothesSize(desiredSize);
  165.                     break;
  166.  
  167.  
  168.                 case "3":
  169.                     System.out.println("Какъв бранд търсите?");
  170.                     String desiredBrand = scan.nextLine();
  171.                     Clothes.getClothesBrand(desiredBrand);
  172.                     break;
  173.  
  174.  
  175.             /*case 4 :
  176.                 System.out.println("За каква цена търсите?");
  177.                 String desiredPrice = scan.nextLine();
  178.                 Clothes.getClothesBrand(desiredPrice);
  179.                 */
  180.  
  181.                 case "4":
  182.                     System.out.println("За кой сезон търсите?");
  183.                     String desiredSeason = scan.nextLine();
  184.                     Clothes.getClothesSeason(desiredSeason);
  185.                     break;
  186.             }
  187.  
  188.  
  189.         }
  190.  
  191.  
  192.  
  193.     }
  194. }
Add Comment
Please, Sign In to add comment