package _05_static_练习.练习3;

public class Product {
    private String productName;
    private double price;

    // 总库存
    public static int totalStock;
    // 总销售额
    public static double totalSalesAmount;

    public Product(String productName, double price) {
        this.productName = productName;
        this.price = price;

        totalStock += 10;
    }

    public void sell(int count){
        if(count > totalStock){
            System.out.println("库存不足");
        }else{
            totalStock -= count;
            totalSalesAmount += count * price;
        }
    }

    public static void showTotalInfo(){
        System.out.println("总库存为:"+ totalStock);
        System.out.println("总营销额为:"+ totalSalesAmount);
    }

    public void showProductInfo(){
        System.out.println("商品名称为:"+ productName+", 商品价格为:"+ price);
    }
}
