You need to sign in to do that
Don't have an account?
Apex Workbook error - Invalid Constructor Name
public class StoreFrontController {
List<DisplayMerchandise> products;
public List<DisplayMerchandise> getProducts() {
if(products == null) {
products = new List<DisplayMerchandise>();
for(Merchandise__c item : [
SELECT Id, Name, Description__c, Price__c, Total_Inventory__c
FROM Merchandise__c]) {
products.add(new DisplayMerchandise(item));
}
}
return products;
}
// Inner class to hold online store details for item public class DisplayMerchandise {
private Merchandise__c merchandise;
public DisplayMerchandise(Merchandise__c item) {
this.merchandise = item;
}
// Properties for use in the Visualforce view public String name {
get { return merchandise.Name; }
}
public String description {
get { return merchandise.Description__c; }
}
public Decimal price {
get { return merchandise.Price__c; }
}
public Boolean inStock {
get { return (0 < merchandise.Total_Inventory__c); }
}
public Integer qtyToBuy { get; set; }
}
}
This code snippet is obtain from Apex Workbook online Chapter 3, Tutorial #17 and Lessonr #5 "Using Inner Classes in an Apex Controller"
When I try to save this class I get an error saying
"Invalid Constructor Name : DisplayMerchandise" (line 20)
I have highlighted the line in red for easy reference.
Can someone tell me whats the issue with the class code ?
The problem is a couple of lines before - the class definition has been tacked on the end of a comment line:
Change this to:
All Answers
The problem is a couple of lines before - the class definition has been tacked on the end of a comment line:
Change this to:
Thanks !!!!!!!!