User Story
Acceptance Criteria:
- The system should have a custom object named "Product" in Salesforce to store product information.
- The "Product" object should have fields for name, price, and quantity.
- The system should provide a default constructor for the "Product" object that initializes the fields with default values.
- The system should provide a parameterized constructor for the "Product" object that accepts the name, price, and quantity as parameters and sets the field values accordingly.
- The "Product" object should have a method to display its details, including the name, price, and quantity.
- The system should allow the creation of product instances using both the default and parameterized constructors.
- The system should have a user-friendly interface to create and manage product records, including the ability to view and modify their details.
- The product details should be easily accessible and searchable within the product management system.
- The system should ensure proper security measures to control access to product information based on user roles and permissions.
Solution
Student Class:
public class Product {
private String name;
private Double price;
private Integer quantity;
public Product() {
this.name = "";
this.price = 0.0;
this.quantity = 0;
}
public Product(String name, Double price, Integer quantity) {
this.name = name;
this.price = price;
this.quantity = quantity;
}
public void displayDetails() {
System.debug('Name: ' + name);
System.debug('Price: ' + price);
System.debug('Quantity: ' + quantity);
}
}
Apex Code:
Product product1 = new Product();
product1.displayDetails();
Product product2 = new Product('iPhone', 999.99, 10);
product2.displayDetails();
Video
Video does not exists.