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);
}
}
}
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;
}
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);
}
}
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);
}
}
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);
}
}
Aggregations