为了账号安全,请及时绑定邮箱和手机立即绑定

error: cannot find symbol

import java.util.*;

import java.io.*;


abstract class BreadType {

private String name;

private double cost;

private double totalSales;

private int soldQuantity;

private int totalBreadTypes;

public BreadType(String name, double cost){

this.name = name;

this.cost = cost;

}

public String getBreadName(){return name;}

public double getBreadCost(){return cost;}

public double getTotalSales(){return totalSales;}

public double getSoldQuantity(){return soldQuantity;}

public double updateCurrentSales(double price, double quantity){

double currentSale = price * quantity;

this.totalSales += currentSale;

this.soldQuantity += quantity;

return currentSale;

}

abstract public int BType();

abstract public double suggestedPrice();

abstract public double totalProfit();

abstract public void showDetails();



}


class Loaf extends BreadType{

private double profitMargin = 0.2;

public Loaf(String breadName, double breadCost){

super(breadName, breadCost);

}

public int BType(){return 2;}

public double sellingBread(double price, double quantity){

return super.updateCurrentSales(price, quantity);

}

public double suggestedPrice(){return getBreadCost() * (1 + profitMargin);}

public double totalProfit(){

return (getTotalSales() - (getBreadCost() * getSoldQuantity()));

}

public void showDetails(){

System.out.println(String.format("%-20s %-15s %-20s %10s %10s %10s %8s",

getBreadName(), "  Loaf", "  " + getBreadCost() + "  Per Piece ",

suggestedPrice(), getSoldQuantity(), "N.A.", getTotalSales()));

}

}


public class Main {


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        BreadType breads = new Loaf("Chese Loaf", 15);

        double price = breads.sellingBread(15.8, 20.2); //!!!這裡報錯了!!!

    }

}


//求問為什麼會報錯, 不太懂,謝謝回答



正在回答

举报

0/150
提交
取消

error: cannot find symbol

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信