Search in sources :

Example 1 with SvProduct

use of com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct in project AN15 by IharDubkou.

the class SvCatalogServiceImpl method showProductsByCategory.

@Override
public void showProductsByCategory(ProductCategory category, SvCatalog catalog) {
    ArrayList<SvProduct> products = catalog.getCatalogList();
    System.out.println("\nВсе товары категории " + category.toString());
    for (SvProduct p : products) {
        if (p.getProductCategory().equals(category)) {
            System.out.println(p);
        }
    }
}
Also used : SvProduct(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct)

Example 2 with SvProduct

use of com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct in project AN15 by IharDubkou.

the class MainTask3 method catalogProductAndCategoryCreator.

static SvCatalog catalogProductAndCategoryCreator() {
    SvCatalog catalog = new SvCatalog();
    catalog.addProduct(new SvProduct(ProductCategory.SPORT, "Мяч", 30, ProductRank.HIGH));
    catalog.addProduct(new SvProduct(ProductCategory.SPORT, "Гиря", 20, ProductRank.HIGH));
    catalog.addProduct(new SvProduct(ProductCategory.ELECTRONIC, "Телефон", 100, ProductRank.HIGH));
    catalog.addProduct(new SvProduct(ProductCategory.ELECTRONIC, "Ноутбук", 210, ProductRank.HIGH));
    catalog.addProduct(new SvProduct(ProductCategory.HOUSEHOLD, "Кофеварка", 170, ProductRank.HIGH));
    catalog.addProduct(new SvProduct(ProductCategory.HOUSEHOLD, "Блендер", 90, ProductRank.HIGH));
    return catalog;
}
Also used : SvCatalog(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvCatalog) SvProduct(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct)

Example 3 with SvProduct

use of com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct in project AN15 by IharDubkou.

the class MainTask3 method svCatalogServiceTest.

static void svCatalogServiceTest(SvCatalog catalog, SvUser user) {
    System.out.println("\nTest CatalogService:");
    SvCatalogServiceImpl service = new SvCatalogServiceImpl();
    service.showAllProducts(catalog);
    service.showProductsByCategory(ProductCategory.ELECTRONIC, catalog);
    // пока не знаю как здесь удобнее реализовать!!!!
    // поэтому хардкорно передаем элемент списка.
    service.addProductInBasket(user, catalog.getCatalogList().get(2));
    service.addProductInBasket(user, new SvProduct(ProductCategory.HOUSEHOLD, "Блендер", 90, ProductRank.HIGH));
    service.buyProduct(user, catalog.getCatalogList().get(2));
    System.out.println("\nЧто может пользователь:");
    for (UsersActions e : UsersActions.values()) {
        System.out.println(e);
    }
}
Also used : SvCatalogServiceImpl(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.services.implimentations.SvCatalogServiceImpl) SvProduct(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct) UsersActions(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.enums.UsersActions)

Example 4 with SvProduct

use of com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct in project AN15 by IharDubkou.

the class SvCatalogServiceImpl method addProductInBasket.

@Override
public void addProductInBasket(SvUser user, SvProduct product) {
    System.out.println("\nКорзина покупателя");
    SvBasket basket = user.getUserBasket();
    basket.addToBasket(product);
    user.setUserBasket(basket);
    System.out.println("В корзине теперь");
    for (SvProduct p : user.getUserBasket().getProductList()) {
        System.out.println(p);
    }
}
Also used : SvBasket(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvBasket) SvProduct(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct)

Example 5 with SvProduct

use of com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct in project AN15 by IharDubkou.

the class SvCatalogServiceImpl method buyProduct.

@Override
public void buyProduct(SvUser user, SvProduct product) {
    System.out.println("\nКорзина покупок");
    for (SvProduct p : user.getUserBasket().getProductList()) {
        System.out.println(p);
    }
    System.out.println("Вы хотите купить");
    System.out.println(product);
    if (user.getUserBasket().productList.contains(product)) {
        System.out.println("Такой товар есть");
        user.getUserBasket().removeFromBasket(product);
    } else {
        System.out.println("Такого нет и что-то там делаем дальше");
    }
    System.out.println("\nКорзина покупок теперь");
    for (SvProduct p : user.getUserBasket().getProductList()) {
        System.out.println(p);
    }
}
Also used : SvProduct(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct)

Aggregations

SvProduct (com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct)6 UsersActions (com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.enums.UsersActions)1 SvBasket (com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvBasket)1 SvCatalog (com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvCatalog)1 SvCatalogServiceImpl (com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.services.implimentations.SvCatalogServiceImpl)1