9class Product implements Entity, Display {
11 public Boolean available
18 * Creates a new product instance.
19 * @param id Product ID.
20 * @param name Product name.
21 * @param available Product availability.
22 * @param price Product price.
23 * @param key Product key.
24 * @param data Product internal data.
26 Product(id, name, available, price, key = "key", data = "internal") {
29 this.available = available
36 * Returns product data as text.
37 * @return Data string.
40 return """ID [${id}] Name [${name}] Available [${available}] Price [${price}]"""
44/* Creates a new product instance */
45def product = new Product(1, "T-Shirt", true, 15.00)
47println(product.asText())
49product.available = false
53assert product.asText() == "ID [1] Name [T-Shirt] Available [false] Price [0.0]"
55def factorial(Integer value) {
59 return value * factorial(value - 1)
63assert factorial(5) == 120
65static String join(List<String> list, String separator) {
69 data += item + separator
72 data = data.substring(0, data.length() - 1)
77assert join(["g", "r", "o", "o", "v", "y"], " ") == "g r o o v y"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list