Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CLOTHES STORE
- import java.util.*;
- public class Clothes {
- public String clotheStyle;
- public String clotheSize;
- private String clotheBrand;
- private float clothePrice;
- private String clotheSeason;
- private static ArrayList<Clothes> clothesStorage = new ArrayList<>();
- static {
- clothesStorage.add(new Clothes("Тениска","XL", "Gucci", 50, "Лято" ));
- clothesStorage.add(new Clothes("Суичър","S", "Nike",50, "Есен" ));
- clothesStorage.add(new Clothes("Анцунг","L", "Flair", 50,"Пролет, есен" ));
- clothesStorage.add(new Clothes("Дънки","XS", "Adidas", 50,"Пролет" ));
- }
- public Clothes(String clotheStyle, String clotheSize, String clotheBrand,float clothePrice, String clotheSeason) {
- this.clotheStyle = clotheStyle;
- this.clotheSize = clotheSize;
- this.clotheBrand = clotheBrand;
- this.clothePrice = clothePrice;
- this.clotheSeason = clotheSeason;
- }
- public String getClotheStyle() {
- return clotheStyle;
- }
- public String getClotheSize() {
- return clotheSize;
- }
- public String getClotheBrand() {
- return clotheBrand;
- }
- public float getClothePrize() {
- return clothePrice;
- }
- public String getClotheSeason() {
- return clotheSeason;
- }
- public void setClotheStyle(String clotheStyle) {this.clotheStyle = clotheStyle;
- }
- public void setClotheSize(String clotheSize) {this.clotheSize = clotheSize;
- }
- public void setClotheBrand(String clotheBrand) {this.clotheBrand = clotheBrand;
- }
- public void setClotheSeason(String clotheSeason) {this.clotheSeason = clotheSeason;
- }
- public void getAllInfo() {
- System.out.println("Стил : " + this.clotheStyle);
- System.out.println("Размер : " + this.clotheSize);
- System.out.println("Бранд : " + this.clotheBrand);
- System.out.println("Цена : " + this.clothePrice + "лева");
- System.out.println("Сезон : " + this.clotheSeason);
- }
- public static void getClothesStyle(String desiredStyle) {
- boolean bStyle = true;
- for (Clothes cl : clothesStorage) {
- if (cl.clotheStyle.equalsIgnoreCase(desiredStyle)) {
- cl.getAllInfo();
- bStyle = false;
- }
- }
- if(bStyle){
- System.out.println("Няма такъв стил ");
- }
- }
- public static void getClothesSize (String desiredSize){
- boolean bSize = true;
- for (Clothes cl : clothesStorage) {
- if (cl.clotheSize.equalsIgnoreCase(desiredSize)) {
- cl.getAllInfo();
- bSize = false;
- }
- }
- if(bSize){
- System.out.println("Няма такъв размер");
- }
- }
- public static void getClothesBrand (String desiredBrand){
- boolean bBrand = true;
- for (Clothes cl : clothesStorage) {
- if (cl.clotheBrand.equalsIgnoreCase(desiredBrand)) {
- cl.getAllInfo();
- bBrand = false;
- }
- }
- if(bBrand){
- System.out.println("Няма такъв бранд");
- }
- }
- public static void getClothesPrice (float desiredPrice){
- boolean bPrice = true;
- for (Clothes cl : clothesStorage) {
- if (cl.clothePrice == desiredPrice) {
- cl.getAllInfo();
- bPrice = false;
- }
- }
- if(bPrice){
- System.out.println("Няма за такава цена");
- }
- }
- public static void getClothesSeason (String desiredSeason){
- boolean bSeason = true;
- for (Clothes cl : clothesStorage) {
- if (cl.clotheSeason.equalsIgnoreCase(desiredSeason)) {
- cl.getAllInfo();
- bSeason = false;
- }
- }
- if(bSeason){
- System.out.println("Няма дреха за такъв сезон");
- }
- }
- }
- ====================================================================
- //MAIN
- import java.util.*;
- public class App {
- Scanner scan = new Scanner(System.in);
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String input = "";
- while (!input.equalsIgnoreCase("стоп")) {
- System.out.println(" 1. Търсене по стил " +
- "\n 2. Търсене по размер " +
- "\n 3. Търсене по бранд" +
- "\n 4. Търсене по сезон");
- input = scan.nextLine();
- switch (input) {
- case "1":
- System.out.println("Какъв стил дрехи търсите?");
- String desiredStyle = scan.nextLine();
- Clothes.getClothesStyle(desiredStyle);
- break;
- case "2":
- System.out.println("Какъв размер търсите?");
- String desiredSize = scan.nextLine();
- Clothes.getClothesSize(desiredSize);
- break;
- case "3":
- System.out.println("Какъв бранд търсите?");
- String desiredBrand = scan.nextLine();
- Clothes.getClothesBrand(desiredBrand);
- break;
- /*case 4 :
- System.out.println("За каква цена търсите?");
- String desiredPrice = scan.nextLine();
- Clothes.getClothesBrand(desiredPrice);
- */
- case "4":
- System.out.println("За кой сезон търсите?");
- String desiredSeason = scan.nextLine();
- Clothes.getClothesSeason(desiredSeason);
- break;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment