package _01_static.demo6;

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 +"---总营销额:"+ totalSalesAmount);
    }

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

    }


}
