我在构造函数中遇到此问题我希望能够从供应商类中获取supplierName并将其添加到产品中。
public class ProductService {
private Map<Long, Product> products = DatabaseClass.getProducts();
public ProductService(){
products.put(1L,new Product(1,1,"Lighter","Gift",5000,"Supplier1"));
products.put(2L,new Product(2,2,"Lighter","Gift",3500,"supplier2"));
}
但问题在于我到达我的产品服务类
supplier1
它给我supplier2
&amp; cv::Mat img = cv::imread("E:\\Workspace\\KS\\excercise\\oBwBH.jpg", 0);
cv::Mat workingMat;
cv::GaussianBlur(img, workingMat, cv::Size(101, 101), 31, 31); //high blur to extract background light
img = img - 0.7*work; //adjust light level
cv::normalize(img, img, 0, 255, cv::NORM_MINMAX); \\use whole range
cv::medianBlur(img, img, 5); \\remove noise
cv::Canny(img, work, 100, 200); \\extract lines; you could do hough lines instead since it has canny inside.
。
任何帮助都会得到满足。
答案 0 :(得分:1)
如果您编辑代码的格式,您可以清楚地看到您尝试将字符串"Supplier1"
和"supplier2"
解析为构造函数,该构造函数接受Supplier
作为对象类型。
如果您有一个已定义的类Supplier
,请将构造函数调用更改为:
products.put(2L,new Product(2,2, "Lighter","Gift",3500,new Supplier(...)));
或者如果供应商应该是String,则更改其声明和构造函数。
private String supplier;
public Product(long id, long barcode, String description, String zone, int quantity, String supplier) { .... }
所有案例的结论是:请格式化!:)
答案 1 :(得分:0)
您在"Supplier1"
和Supplier2
中提供字符串,而构造函数需要对象"Supplier"